Skip to content

Commit

Permalink
Revert "Stop unquoting %2F in paths (#1057)"
Browse files Browse the repository at this point in the history
This reverts commit 84e1c7d.
  • Loading branch information
bdraco committed Sep 23, 2024
1 parent 6795a59 commit 9717ef0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
7 changes: 0 additions & 7 deletions tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,6 @@ def test_path_with_spaces():
assert "/a b" == url.path


def test_path_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 == "/foo/bar%2Fbaz"


def test_raw_path_for_empty_url():
url = URL()
assert "" == url.raw_path
Expand Down
4 changes: 1 addition & 3 deletions yarl/_quoting_c.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@ class _Quoter:
def __call__(self, val: str = ...) -> str: ...

class _Unquoter:
def __init__(
self, *, ignore: str = ..., unsafe: str = ..., qs: bool = ...
) -> None: ...
def __init__(self, *, unsafe: str = ..., qs: bool = ...) -> None: ...
def __call__(self, val: str = ...) -> str: ...
6 changes: 2 additions & 4 deletions yarl/_quoting_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,12 @@ cdef class _Quoter:


cdef class _Unquoter:
cdef str _ignore
cdef str _unsafe
cdef bint _qs
cdef _Quoter _quoter
cdef _Quoter _qs_quoter

def __init__(self, *, ignore="", unsafe="", qs=False):
self._ignore = ignore
def __init__(self, *, unsafe='', qs=False):
self._unsafe = unsafe
self._qs = qs
self._quoter = _Quoter()
Expand Down Expand Up @@ -338,7 +336,7 @@ cdef class _Unquoter:
buflen = 0
if self._qs and unquoted in '+=&;':
ret.append(self._qs_quoter(unquoted))
elif unquoted in self._unsafe or unquoted in self._ignore:
elif unquoted in self._unsafe:
ret.append(self._quoter(unquoted))
else:
ret.append(unquoted)
Expand Down
5 changes: 2 additions & 3 deletions yarl/_quoting_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ def __call__(self, val: str) -> str:


class _Unquoter:
def __init__(self, *, ignore: str = "", unsafe: str = "", qs: bool = False) -> None:
self._ignore = ignore
def __init__(self, *, unsafe: str = "", qs: bool = False) -> None:
self._unsafe = unsafe
self._qs = qs
self._quoter = _Quoter()
Expand Down Expand Up @@ -159,7 +158,7 @@ def __call__(self, val: str) -> str:
if to_add is None: # pragma: no cover
raise RuntimeError("Cannot quote None")
ret.append(to_add)
elif unquoted in self._unsafe or unquoted in self._ignore:
elif unquoted in self._unsafe:
to_add = self._quoter(unquoted)
if to_add is None: # pragma: no cover
raise RuntimeError("Cannot quote None")
Expand Down
2 changes: 1 addition & 1 deletion yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9717ef0

Please sign in to comment.