Skip to content

Commit

Permalink
Fix double unquoting in url dispatcher
Browse files Browse the repository at this point in the history
#8898 now passes the unquoted path and we would
unquote it again
  • Loading branch information
bdraco committed Sep 23, 2024
1 parent 3eb7282 commit 2731a1a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,7 @@ def _match(self, path: str) -> Optional[Dict[str, str]]:
if match is None:
return None
else:
return {
key: _unquote_path(value) for key, value in match.groupdict().items()
}
return {key: value for key, value in match.groupdict().items()}

def raw_match(self, path: str) -> bool:
return self._orig_path == path
Expand Down Expand Up @@ -654,7 +652,7 @@ async def resolve(self, request: Request) -> _Resolve:
if method not in allowed_methods:
return None, allowed_methods

match_dict = {"filename": _unquote_path(path[len(self._prefix) + 1 :])}
match_dict = {"filename": path[len(self._prefix) + 1 :]}
return (UrlMappingMatchInfo(match_dict, self._routes[method]), allowed_methods)

def __len__(self) -> int:
Expand Down Expand Up @@ -1286,10 +1284,6 @@ def _quote_path(value: str) -> str:
return URL.build(path=value, encoded=False).raw_path


def _unquote_path(value: str) -> str:
return URL.build(path=value, encoded=True).path.replace("%2F", "/")


def _requote_path(value: str) -> str:
# Quote non-ascii characters and other characters which must be quoted,
# but preserve existing %-sequences.
Expand Down

0 comments on commit 2731a1a

Please sign in to comment.