Skip to content

Commit

Permalink
Fixes error with international URLs that have more than 2 hyphens (#184)
Browse files Browse the repository at this point in the history
* Adds support for emojis and more IDNA URLs

* Adds setup_requires parameter

* Validates URLs with IPs ending in .0 or .255

* Fixed flake8 errors

* Revert "Adds setup_requires parameter"

This reverts commit 42ea2fd.

* Fixes international domains with more than 2 hyphens

Co-authored-by: Matthew Wilson <Matthew.Wilson@53.com>
  • Loading branch information
automationator and Matthew Wilson committed Jun 5, 2022
1 parent 38e9fc9 commit 67c57f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/test_url.py
Expand Up @@ -46,6 +46,8 @@
u'http://😉.com/😁',
u'http://উদাহরণ.বাংলা',
u'http://xn--d5b6ci4b4b3a.xn--54b7fta0cc',
u'http://дом-м.рф/1/asdf',
u'http://xn----gtbybh.xn--p1ai/1/asdf',
u'http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com',
u'http://1337.net',
u'http://a.b-c.de',
Expand Down
6 changes: 3 additions & 3 deletions validators/url.py
Expand Up @@ -69,13 +69,13 @@
r"(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
r")\]|"
# host name
r"(?:(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"(?:(?:(?:xn--[-]{0,2})|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)"
# domain name
r"(?:\.(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"(?:\.(?:(?:xn--[-]{0,2})|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)*"
# TLD identifier
r"(?:\.(?:(?:xn--[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|"
r"(?:\.(?:(?:xn--[-]{0,2}[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|"
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff]{2,}))"
r")"
# port number
Expand Down

0 comments on commit 67c57f4

Please sign in to comment.