From 486429b5a1748983eda6d52fc6e7d8706aee77a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20S=C3=A9bille?= Date: Mon, 16 Oct 2017 13:18:46 +0200 Subject: [PATCH] parts.publish: Properly quote the root prefix ('.') Since Python3.5 the behavior of urllib changed, '/./' was previously left untouched but now it is simplified to '/'. The aptly documentation tell us to use ':.' instead of '.' because ". is ambigious in URLs". --- aptly_api/parts/publish.py | 2 ++ aptly_api/tests/publish.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/aptly_api/parts/publish.py b/aptly_api/parts/publish.py index 6891396..c6c3af9 100644 --- a/aptly_api/parts/publish.py +++ b/aptly_api/parts/publish.py @@ -40,6 +40,8 @@ def endpoint_from_response(api_response: Union[Dict[str, str], Dict[str, List[st @staticmethod def escape_prefix(prefix: str) -> str: + if prefix == ".": + return ":." if "/" in prefix: # prefix has not yet been quoted as described at # https://www.aptly.info/doc/api/publish/ diff --git a/aptly_api/tests/publish.py b/aptly_api/tests/publish.py index 4385f46..b9dc8b6 100644 --- a/aptly_api/tests/publish.py +++ b/aptly_api/tests/publish.py @@ -281,3 +281,7 @@ def test_escape_prefix(self, *args: Any, **kwargs: Any) -> None: self.papi.escape_prefix("test/a"), "test_a" ) + self.assertEqual( + self.papi.escape_prefix("."), + ":." + )