Skip to content

Commit

Permalink
prove YARL_NO_EXTENSIONS=1 deviation
Browse files Browse the repository at this point in the history
  • Loading branch information
pajod authored and webknjaz committed Jun 28, 2024
1 parent 0baa61a commit 753781a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_url_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,3 +580,34 @@ def test_empty_path(self):
assert u.path == ""
assert u.query_string == ""
assert u.fragment == ""

def test_truncated_utf_sequence(self):
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#"
abspath, _hash_separator, frag = raw_path.decode(
"utf-8", "surrogateescape"
).partition("#")
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7")
assert u.scheme == ""
assert u.user is None
assert u.password is None
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
assert u.query_string == ""
assert u.fragment == ""
assert u.path == u2.path

Check warning on line 597 in tests/test_url_parsing.py

View check run for this annotation

Codecov / codecov/patch

tests/test_url_parsing.py#L584-L597

Added lines #L584 - L597 were not covered by tests

def test_truncated_utf_sequence_frag(self):
raw_path = b"/P\xc3\xbcnktchen\xa0\xef\xb7#P\xc3\xbcnktelchen\xa0\xef\xb6"
abspath, _hash_separator, frag = raw_path.decode(
"utf-8", "surrogateescape"
).partition("#")
u = URL.build(path=abspath, query_string="", fragment=frag, encoded=True)
u2 = URL("/P%C3%BCnktchen\udca0\udcef\udcb7#Pünktelchen\udca0\udcef\udcb6")
assert u.scheme == ""
assert u.user is None
assert u.password is None
assert u.path == "/Pünktchen\udca0\udcef\udcb7"
assert u.query_string == ""
assert u.fragment == "Pünktelchen\udca0\udcef\udcb6"
assert u.path == u2.path

Check warning on line 612 in tests/test_url_parsing.py

View check run for this annotation

Codecov / codecov/patch

tests/test_url_parsing.py#L599-L612

Added lines #L599 - L612 were not covered by tests
# assert u.fragment == u2.fragment

0 comments on commit 753781a

Please sign in to comment.