Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test_urlnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def pytest_generate_tests(metafunc):
for url in [
'-',
'asdf',
'http://./',
'HTTP://4294967297/test', # one more than max ip > int
'http://[img]http://i790.photobucket.com/albums/yy185/zack-32009/jordan.jpg[/IMG]',
]:
Expand Down
4 changes: 4 additions & 0 deletions urlnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ def norm_netloc(scheme, netloc):
if host[-1] == '.':
host = host[:-1]

# bracket check is for ipv6 hosts
if not host or ('.' not in host and not (host[0] == '[' and host[-1] == ']')):
raise InvalidUrl('host %r is not valid' % host)

authority = lower(host)
if 'xn--' in authority:
subdomains = [_idn(subdomain) for subdomain in authority.split('.')]
Expand Down