Skip to content

Commit bc8a244

Browse files
committed
prove YARL_NO_EXTENSIONS=1 deviation
moved from aio-libs/aiohttp#8088
1 parent bd5ff24 commit bc8a244

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
@@ -584,3 +584,34 @@ def test_empty_path(self):
584584
assert u.path == ""
585585
assert u.query_string == ""
586586
assert u.fragment == ""
587+
588+
def test_truncated_utf_sequence(self):
589+
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#"
590+
abspath, _hash_separator, frag = raw_path.decode(
591+
"utf-8", "surrogateescape"
592+
).partition("#")
593+
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
594+
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7")
595+
assert u.scheme == ""
596+
assert u.user is None
597+
assert u.password is None
598+
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
599+
assert u.query_string == ""
600+
assert u.fragment == ""
601+
assert u.path == u2.path
602+
603+
def test_truncated_utf_sequence_frag(self):
604+
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#P\xc3\xbcnktelchen\xa0\xef\xb6"
605+
abspath, _hash_separator, frag = raw_path.decode(
606+
"utf-8", "surrogateescape"
607+
).partition("#")
608+
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
609+
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7#Pünktelchen\udca0\udcef\udcb6")
610+
assert u.scheme == ""
611+
assert u.user is None
612+
assert u.password is None
613+
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
614+
assert u.query_string == ""
615+
assert u.fragment == "Pünktelchen\udca0\udcef\udcb6"
616+
assert u.path == u2.path
617+
# assert u.fragment == u2.fragment

0 commit comments

Comments
 (0)