Skip to content

Commit 67c57f4

Browse files
automationatorMatthew Wilson
andauthored
Fixes error with international URLs that have more than 2 hyphens (#184)
* 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 <[email protected]>
1 parent 38e9fc9 commit 67c57f4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tests/test_url.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
u'http://😉.com/😁',
4747
u'http://উদাহরণ.বাংলা',
4848
u'http://xn--d5b6ci4b4b3a.xn--54b7fta0cc',
49+
u'http://дом-м.рф/1/asdf',
50+
u'http://xn----gtbybh.xn--p1ai/1/asdf',
4951
u'http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com',
5052
u'http://1337.net',
5153
u'http://a.b-c.de',

validators/url.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@
6969
r"(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
7070
r")\]|"
7171
# host name
72-
r"(?:(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
72+
r"(?:(?:(?:xn--[-]{0,2})|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
7373
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)"
7474
# domain name
75-
r"(?:\.(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
75+
r"(?:\.(?:(?:xn--[-]{0,2})|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
7676
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)*"
7777
# TLD identifier
78-
r"(?:\.(?:(?:xn--[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|"
78+
r"(?:\.(?:(?:xn--[-]{0,2}[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|"
7979
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff]{2,}))"
8080
r")"
8181
# port number

0 commit comments

Comments
 (0)