Skip to content

Commit

Permalink
Updated Validate.record_hostname() to support second level names
Browse files Browse the repository at this point in the history
  • Loading branch information
shupp committed Apr 21, 2015
1 parent b6b39a3 commit fd3f179
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_ipv6_invalid(self):
self.assertFalse(Validate.ipv6('i like turtles'))

def test_record_name_valid(self):
self.assertTrue(Validate.record_hostname('vegadns.org'))
self.assertTrue(Validate.record_hostname('www.vegadns.org'))
self.assertTrue(Validate.record_hostname('foo.www.vegadns.org'))
self.assertTrue(Validate.record_hostname('bar.foo.www.vegadns.org'))
Expand Down
6 changes: 3 additions & 3 deletions vegadns/validate/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def ipv6(ipv6_address):

@staticmethod
def record_hostname(hostname):
# All record hostnames must be at least a third level
if hostname.count('.') <= 1:
# All record hostnames must be at least a second level
if hostname.count('.') < 1:
return False

# Currently only allowing a-z,0-9,- etc per old app
# May want to revisit this for non-alphanumeric support
# This needs revisiting to be RFC compliant
p = re.compile(
'^([\*a-z0-9-\/]+[\.])+[a-z0-9-]+[\.]{0,1}$',
re.IGNORECASE
Expand Down

0 comments on commit fd3f179

Please sign in to comment.