From 06ed15ecb2a4700a08f4f2ff4b03bd751ca979f6 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 17 Jan 2018 10:44:24 +0200 Subject: [PATCH] Fix #2670: Process colon in path correctly. Release 2.3.9 --- CHANGES.rst | 5 +++++ aiohttp/__init__.py | 2 +- aiohttp/web_urldispatcher.py | 3 ++- tests/test_urldispatch.py | 12 ++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7e7962a0540..f606df08f9c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,11 @@ Changelog .. towncrier release notes start +2.3.9 (2018-01-16) +================== + +- Fix colon handing in path for dynamic resources (#2670) + 2.3.8 (2018-01-15) ================== diff --git a/aiohttp/__init__.py b/aiohttp/__init__.py index 287f906e000..c5406cbea82 100644 --- a/aiohttp/__init__.py +++ b/aiohttp/__init__.py @@ -1,4 +1,4 @@ -__version__ = '2.3.8' +__version__ = '2.3.9' # This relies on each of the submodules having an __all__ variable. diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py index 46fcfac73dd..cbc5e3b2cea 100644 --- a/aiohttp/web_urldispatcher.py +++ b/aiohttp/web_urldispatcher.py @@ -427,7 +427,8 @@ def _match(self, path): if match is None: return None else: - return {key: URL(value, encoded=True).path for key, value in + return {key: URL.build(path=value, encoded=True).path + for key, value in match.groupdict().items()} def get_info(self): diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index 00a317fd7cb..b1a39285e8e 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -107,6 +107,18 @@ def test_add_with_matchdict(router): assert info.route.name is None +@asyncio.coroutine +def test_add_with_matchdict_with_colon(router): + handler = make_handler() + router.add_route('GET', '/handler/{to}', handler) + req = make_request('GET', '/handler/1:2:3') + info = yield from router.resolve(req) + assert info is not None + assert {'to': '1:2:3'} == info + assert handler is info.handler + assert info.route.name is None + + @asyncio.coroutine def test_add_route_with_add_get_shortcut(router): handler = make_handler()