Skip to content

Commit c25e8b4

Browse files
committed
Add tests for URLs with non-IDNA-encodable netlocs
1 parent bfcdde7 commit c25e8b4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_url.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@ def test_safe_url_idna(self):
165165
safeurl = safe_url_string(safe_result)
166166
self.assertEqual(safeurl, safe_result)
167167

168+
def test_safe_url_idna_encoding_failure(self):
169+
# missing DNS label
170+
self.assertEqual(
171+
safe_url_string(u"http://.example.com/résumé?q=résumé"),
172+
"http://.example.com/r%C3%A9sum%C3%A9?q=r%C3%A9sum%C3%A9")
173+
174+
# DNS label too long
175+
self.assertEqual(
176+
safe_url_string(
177+
u"http://www.{label}.com/résumé?q=résumé".format(
178+
label=u"example"*11)),
179+
"http://www.{label}.com/r%C3%A9sum%C3%A9?q=r%C3%A9sum%C3%A9".format(
180+
label=u"example"*11))
181+
168182
def test_safe_download_url(self):
169183
self.assertEqual(safe_download_url('http://www.example.org'),
170184
'http://www.example.org/')

0 commit comments

Comments
 (0)