mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-10 23:08:23 +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:
parent
ac3df58a3f
commit
0c45032178
@ -39,7 +39,7 @@ def validate_hostname(data):
|
|||||||
if re.search(r'(\.-)|(-\.)', namepart):
|
if re.search(r'(\.-)|(-\.)', namepart):
|
||||||
raise forms.ValidationError('Hostname contain ".-" or "-."')
|
raise forms.ValidationError('Hostname contain ".-" or "-."')
|
||||||
# Must not contain '--' except in 'xn--' for IDN
|
# 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')
|
raise forms.ValidationError('Hostname contain "--" and it\'s not an IDN')
|
||||||
# Certain hostnames reserved for project use are not allowed
|
# Certain hostnames reserved for project use are not allowed
|
||||||
if re.search(r'(^|\.)(proxy|router|console)$', namepart):
|
if re.search(r'(^|\.)(proxy|router|console)$', namepart):
|
||||||
|
Loading…
Reference in New Issue
Block a user