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

validation.py: Allow only 4ld domains and below

This commit is contained in:
Hidden Z 2010-10-22 18:29:42 +00:00
parent 0c45032178
commit 2ab7b2de5f

View File

@ -26,6 +26,9 @@ def validate_hostname(data):
# Must not contain '..'
if re.search(r'\.\.', data):
raise forms.ValidationError('".." in hostname')
# Allow only 4ld domains and below
if data.count('.') > 3:
raise forms.ValidationError('Subdomains deeper than 4LD are not allowed')
# Must contain only [a-z] [0-9] '.' and '-'
h = re.match(r'([a-z0-9.-]+)\.i2p$', data)
if h == None: