From bcf8927f80c2068efb4d47d881c662f88d66b047 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Mon, 23 Sep 2024 19:28:19 +0100 Subject: [PATCH] Update test_url.py --- tests/test_url.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_url.py b/tests/test_url.py index 085cf78d8..68d368390 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -352,6 +352,22 @@ def test_path_with_2F(): assert url.path == "/foo/bar%2Fbaz" +def test_path_safe_with_2F(): + """Path should not decode %2F, otherwise it may look like a path separator.""" + + url = URL("http://example.com/foo/bar%2fbaz") + assert url.path_safe == "/foo/bar%2Fbaz" + + +def test_path_safe_with_25(): + """Path should not decode %25, otherwise it is prone to double unquoting.""" + + url = URL("http://example.com/foo/bar%252Fbaz") + assert url.path_safe == "/foo/bar%252Fbaz" + unquoted = url.path_safe.replace("%2F", "/").replace("%25", "%") + assert unquoted == "/foo/bar%2Fbaz" + + def test_raw_path_for_empty_url(): url = URL() assert "" == url.raw_path