From 6fadd39aeafcc5ff0a53aa43886444df4a631ae8 Mon Sep 17 00:00:00 2001 From: kaiyou Date: Sun, 6 Jan 2019 13:21:00 +0100 Subject: [PATCH] Merge pull request #3 from Nebukadneza/add_key_url_quoting URL-Quote the key in HTTP requests --- core/base/libs/podop/podop/table.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/base/libs/podop/podop/table.py b/core/base/libs/podop/podop/table.py index 3869cafc..0f1ea680 100644 --- a/core/base/libs/podop/podop/table.py +++ b/core/base/libs/podop/podop/table.py @@ -3,7 +3,7 @@ import aiohttp import logging - +from urllib.parse import quote class UrlTable(object): """ Resolve an entry by querying a parametrized GET URL. @@ -23,7 +23,8 @@ class UrlTable(object): if ns is not None: key += "/" + ns async with aiohttp.ClientSession() as session: - async with session.get(self.url_pattern.format(key)) as request: + quoted_key = quote(key) + async with session.get(self.url_pattern.format(quoted_key)) as request: if request.status == 200: result = await request.json() logging.debug("Table get {} is {}".format(key, result)) @@ -40,7 +41,8 @@ class UrlTable(object): if ns is not None: key += "/" + ns async with aiohttp.ClientSession() as session: - await session.post(self.url_pattern.format(key), json=value) + quoted_key = quote(key) + await session.post(self.url_pattern.format(quoted_key), json=value) async def iter(self, cat): """ Iterate the given key (experimental)