Skip to content

Commit 753781a

Browse files
pajodwebknjaz
authored andcommitted
prove YARL_NO_EXTENSIONS=1 deviation
moved from aio-libs/aiohttp#8088
1 parent 0baa61a commit 753781a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_url_parsing.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,3 +580,34 @@ def test_empty_path(self):
580580
assert u.path == ""
581581
assert u.query_string == ""
582582
assert u.fragment == ""
583+
584+
def test_truncated_utf_sequence(self):
585+
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#"
586+
abspath, _hash_separator, frag = raw_path.decode(
587+
"utf-8", "surrogateescape"
588+
).partition("#")
589+
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
590+
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7")
591+
assert u.scheme == ""
592+
assert u.user is None
593+
assert u.password is None
594+
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
595+
assert u.query_string == ""
596+
assert u.fragment == ""
597+
assert u.path == u2.path
598+
599+
def test_truncated_utf_sequence_frag(self):
600+
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#P\xc3\xbcnktelchen\xa0\xef\xb6"
601+
abspath, _hash_separator, frag = raw_path.decode(
602+
"utf-8", "surrogateescape"
603+
).partition("#")
604+
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
605+
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7#Pünktelchen\udca0\udcef\udcb6")
606+
assert u.scheme == ""
607+
assert u.user is None
608+
assert u.password is None
609+
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
610+
assert u.query_string == ""
611+
assert u.fragment == "Pünktelchen\udca0\udcef\udcb6"
612+
assert u.path == u2.path
613+
# assert u.fragment == u2.fragment

0 commit comments

Comments
 (0)