From 497752c16f0514afffb1ce17af21b63e19e98590 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Sep 2024 13:37:45 -0500 Subject: [PATCH] Restore unquoting of %2F in paths (#1151) --- CHANGES/1151.breaking.rst | 3 +++ tests/test_url.py | 4 ++-- yarl/_url.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 CHANGES/1151.breaking.rst diff --git a/CHANGES/1151.breaking.rst b/CHANGES/1151.breaking.rst new file mode 100644 index 000000000..0eed99ff4 --- /dev/null +++ b/CHANGES/1151.breaking.rst @@ -0,0 +1,3 @@ +Restore decoding ``%2F`` (``/``) in ``URL.path`` -- by :user:`bdraco`. + +This change restored the behavior before :issue:`1136`. diff --git a/tests/test_url.py b/tests/test_url.py index 085cf78d8..45d709025 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -346,10 +346,10 @@ def test_path_with_spaces(): def test_path_with_2F(): - """Path should not decode %2F, otherwise it may look like a path separator.""" + """Path should decode %2F.""" url = URL("http://example.com/foo/bar%2fbaz") - assert url.path == "/foo/bar%2Fbaz" + assert url.path == "/foo/bar/baz" def test_raw_path_for_empty_url(): diff --git a/yarl/_url.py b/yarl/_url.py index 01f9d8fab..f506eac6f 100644 --- a/yarl/_url.py +++ b/yarl/_url.py @@ -225,7 +225,7 @@ class URL: _FRAGMENT_REQUOTER = _Quoter(safe="?/:@") _UNQUOTER = _Unquoter() - _PATH_UNQUOTER = _Unquoter(ignore="/", unsafe="+") + _PATH_UNQUOTER = _Unquoter(unsafe="+") _QS_UNQUOTER = _Unquoter(qs=True) _val: SplitResult