Skip to content

Commit

Permalink
Issue IDNAError for the U-label "xn--" (fixes #82)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjd committed Mar 14, 2020
1 parent 133fc01 commit efc1607
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions idna/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ def ulabel(label):
label = label.lower()
if label.startswith(_alabel_prefix):
label = label[len(_alabel_prefix):]
if not label:
raise IDNAError('Malformed A-label, no Punycode eligible content found')
if label.decode('ascii')[-1] == '-':
raise IDNAError('A-label must not end with a hyphen')
else:
Expand Down
1 change: 1 addition & 0 deletions tests/test_idna.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def test_decode(self):
u'\u0521\u0525\u0523-\u0523\u0523-----\u0521\u0523\u0523\u0523.aa')
self.assertRaises(idna.IDNAError, idna.decode, 'XN---------90GGLBAGAAC.AA')
self.assertRaises(idna.IDNAError, idna.decode, 'xn---------90gglbagaac.aa')
self.assertRaises(idna.IDNAError, idna.decode, 'xn--')

if __name__ == '__main__':
unittest.main()

2 comments on commit efc1607

@olaure
Copy link

@olaure olaure commented on efc1607 May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjd Hello Kim, would it be possible to generate a new release with this fix?
The current version on pypi (2.9) is broken.

Many thanks in advance!

@kjd
Copy link
Owner Author

@kjd kjd commented on efc1607 Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder! Will try and post a new release in the coming days.

Please sign in to comment.