From 6d6f222da442ed4f708298e51b0329711ad752a3 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 27 Apr 2017 11:50:26 -0700 Subject: [PATCH] Do not unquote in match_info values #1816 --- CHANGES.rst | 2 ++ aiohttp/web_urldispatcher.py | 2 +- tests/test_urldispatch.py | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c106760c006..7283d2b4cd8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -29,6 +29,8 @@ Changes - Fix assertion errors in Python 3.4 from noop helper. #1847 +- Do not unquote `+` in match_info values #1816 + 2.0.7 (2017-04-12) ------------------ diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py index dddece7ee79..d901988a9c0 100644 --- a/aiohttp/web_urldispatcher.py +++ b/aiohttp/web_urldispatcher.py @@ -346,7 +346,7 @@ def _match(self, path): if match is None: return None else: - return {key: unquote(value) for key, value in + return {key: unquote(value, unsafe='+') for key, value in match.groupdict().items()} def get_info(self): diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index 6a0af0df40a..49821dbf5ee 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -538,6 +538,16 @@ def test_regular_match_info(router): repr(match_info)) +@asyncio.coroutine +def test_match_info_with_plus(router): + handler = make_handler() + router.add_route('GET', '/get/{version}', handler) + + req = make_request('GET', '/get/1.0+test') + match_info = yield from router.resolve(req) + assert {'version': '1.0+test'} == match_info + + @asyncio.coroutine def test_not_found_repr(router): req = make_request('POST', '/path/to')