From b9bff9fe540596860e8906bedc42b82f0159575b Mon Sep 17 00:00:00 2001 From: Bernhard Suttner Date: Tue, 24 Sep 2024 19:07:22 +0200 Subject: [PATCH] Fix URL encoding issue in pulp_file closes #5686 --- CHANGES/pulp_file/5686.txt | 1 + pulp_file/app/tasks/synchronizing.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 CHANGES/pulp_file/5686.txt diff --git a/CHANGES/pulp_file/5686.txt b/CHANGES/pulp_file/5686.txt new file mode 100644 index 0000000000..9b3605eb58 --- /dev/null +++ b/CHANGES/pulp_file/5686.txt @@ -0,0 +1 @@ +During sync, quote the URL path for file downloads using HTTP. diff --git a/pulp_file/app/tasks/synchronizing.py b/pulp_file/app/tasks/synchronizing.py index e7eaca0a23..dca6b76a80 100644 --- a/pulp_file/app/tasks/synchronizing.py +++ b/pulp_file/app/tasks/synchronizing.py @@ -2,7 +2,7 @@ import os from gettext import gettext as _ -from urllib.parse import urlparse, urlunparse +from urllib.parse import quote, urlparse, urlunparse from django.core.files import File @@ -114,6 +114,9 @@ async def run(self): for entry in entries: path = os.path.join(root_dir, entry.relative_path) + if not parsed_url.scheme == "file": + path = quote(path, safe=":/") + url = urlunparse(parsed_url._replace(path=path)) file = FileContent(relative_path=entry.relative_path, digest=entry.digest) artifact = Artifact(size=entry.size, sha256=entry.digest)