From 525321c9fff5e881e5b851f70eae51445c98b24b Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:54:12 -0400 Subject: [PATCH] Fix URL quoting for collection info (#72) * bump dohq-artifactory * quote URL parameters * bump dohq-artifactory in setup.cfg * add changelog fragment * update changelog fragment --- changelogs/fragments/72-fix-url-quoting.yml | 9 +++++++++ galactory/upstream.py | 2 +- galactory/utilities.py | 9 ++++++++- requirements.txt | 2 +- setup.cfg | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/72-fix-url-quoting.yml diff --git a/changelogs/fragments/72-fix-url-quoting.yml b/changelogs/fragments/72-fix-url-quoting.yml new file mode 100644 index 0000000..b3b0036 --- /dev/null +++ b/changelogs/fragments/72-fix-url-quoting.yml @@ -0,0 +1,9 @@ +--- +minor_changes: + - the minimum required version of ``dohq-artifactory`` is now ``v0.9.0`` (https://github.com/briantist/galactory/pull/72). + +bugfixes: + - traceback when publishing or retrieving a previously published collection (even by proxying) whose metadata contains certain characters that need to be URL quoted (https://github.com/briantist/galactory/issues/58, https://github.com/briantist/galactory/issues/52). + +known_issues: + - any collections already published with malformed metadata due to the bug in ``collection_info`` will not be fixed and will need to be re-published or have their collection info repaired (https://github.com/briantist/galactory/pull/72). diff --git a/galactory/upstream.py b/galactory/upstream.py index 089d7bc..9cbce5d 100644 --- a/galactory/upstream.py +++ b/galactory/upstream.py @@ -145,7 +145,7 @@ def _set_cache(self, request, cache) -> None: cache.update() json.dump(cache._to_serializable_dict(), buffer, default=DateTimeIsoFormatJSONProvider.default) buffer.seek(0) - path.deploy(buffer) + path.deploy(buffer, quote_parameters=True) @contextmanager def proxy_download(self, request): diff --git a/galactory/utilities.py b/galactory/utilities.py index 6c9e283..2c08fd3 100644 --- a/galactory/utilities.py +++ b/galactory/utilities.py @@ -260,7 +260,14 @@ def upload_collection_from_hashed_tempfile(artifact: ArtifactoryPath, tmpfile: H params = {} try: - artifact.deploy(tmpfile.handle, md5=tmpfile.md5, sha1=tmpfile.sha1, sha256=tmpfile.sha256, parameters=params) + artifact.deploy( + tmpfile.handle, + md5=tmpfile.md5, + sha1=tmpfile.sha1, + sha256=tmpfile.sha256, + parameters=params, + quote_parameters=True + ) except ArtifactoryException as exc: cause = exc.__cause__ current_app.logger.debug(cause) diff --git a/requirements.txt b/requirements.txt index 63d8d7c..3d7b67d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -dohq-artifactory>=0.8,<0.9 +dohq-artifactory>=0.9,<0.10 Flask>=2.1,<3 semver>=2,<3 base64io>=1,<2 diff --git a/setup.cfg b/setup.cfg index 7322d67..b88171e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ zip_safe = True include_package_data = True python_requires = >= 3.6 install_requires = - dohq-artifactory>=0.8,<0.9 + dohq-artifactory>=0.9,<0.10 Flask>=2.1,<3 semver>=2,<3 base64io>=1,<2