Skip to content

Commit

Permalink
Check a-label does not contain a trailing hyphen (#64)
Browse files Browse the repository at this point in the history
From RFC5891 § 4.2.1
 "If only an A-label was provided and the conversion to a U-label is
  not performed, the registry MUST still verify that the A-label is
  superficially valid, i.e., that it does not violate any of the rules
  of Punycode encoding [RFC3492] such as the prohibition on trailing
  hyphen-minus, (...)"
  • Loading branch information
j-bernard authored and kjd committed Dec 4, 2018
1 parent 1cdf175 commit 032fc55
Showing 1 changed file with 2 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 label.decode('ascii')[-1] == '-':
raise IDNAError('A-label must not end with a hyphen')
else:
check_label(label)
return label.decode('ascii')
Expand Down

0 comments on commit 032fc55

Please sign in to comment.