1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-10 14:58:05 +00:00

validation.py: enhance IDN-check

Previously olny IDN hostnames which starts with xn-- was allowed, now
subdomains like subdomains.xn--foobar.i2p are also allowed.
This commit is contained in:
Hidden Z 2010-10-22 18:02:47 +00:00
parent ac3df58a3f
commit 0c45032178

View File

@ -39,7 +39,7 @@ def validate_hostname(data):
if re.search(r'(\.-)|(-\.)', namepart):
raise forms.ValidationError('Hostname contain ".-" or "-."')
# Must not contain '--' except in 'xn--' for IDN
if re.search(r'(?<!^xn)--', namepart):
if re.search(r'(?<!^xn)--', namepart) and re.search(r'(?<!\.xn)--', namepart):
raise forms.ValidationError('Hostname contain "--" and it\'s not an IDN')
# Certain hostnames reserved for project use are not allowed
if re.search(r'(^|\.)(proxy|router|console)$', namepart):