Skip to content

Commit

Permalink
Fix for URLs with invalid characters in userinfo part (#70)
Browse files Browse the repository at this point in the history
* Add another invalid test URL; #69

* Be stricter in characters allowed in userinfo URL part; #69

* Break long line for pep8 compliance; #69
  • Loading branch information
timb07 authored and kvesteri committed Jan 30, 2018
1 parent 2d10184 commit 8bd7514
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/test_url.py
Expand Up @@ -116,7 +116,8 @@ def test_returns_true_on_valid_public_url(address, public):
'http://.www.foo.bar/',
'http://www.foo.bar./',
'http://.www.foo.bar./',
'http://127.12.0.260'
'http://127.12.0.260',
'http://example.com/">user@example.com',
])
def test_returns_failed_validation_on_invalid_url(address):
assert isinstance(url(address), ValidationFailure)
Expand Down
7 changes: 5 additions & 2 deletions validators/url.py
Expand Up @@ -10,7 +10,8 @@
# protocol identifier
u"(?:(?:https?|ftp)://)"
# user:pass authentication
u"(?:\S+(?::\S*)?@)?"
u"(?:[-a-z\u00a1-\uffff0-9._~%!$&'()*+,;=:]+"
u"(?::[-a-z0-9._~%!$&'()*+,;=:]*)?@)?"
u"(?:"
u"(?P<private_ip>"
# IP address exclusion
Expand Down Expand Up @@ -43,9 +44,11 @@
# port number
u"(?::\d{2,5})?"
# resource path
u"(?:/\S*)?"
u"(?:/[-a-z\u00a1-\uffff0-9._~%!$&'()*+,;=:@/]*)?"
# query string
u"(?:\?\S*)?"
# fragment
u"(?:#\S*)?"
u"$",
re.UNICODE | re.IGNORECASE
)
Expand Down

0 comments on commit 8bd7514

Please sign in to comment.