From e5fd78d0ea674ca9aa0236c336bf39f27cff06eb Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez <ryan.gonzalez@collabora.com> Date: Fri, 27 Sep 2024 15:03:49 -0500 Subject: [PATCH] Fix double-escaping of path segments on 1.6.1+ As of: https://github.com/openSUSE/osc/commit/3f14cef53a853296d7f60bf7b14eb86615842cf9 `osc.core.makeurl` will escape path comonents itself, so calling `pathname2url` ends up double-escaping, resulting in 404 errors with filenames that have special characters. Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com> --- osc_plugin_dput/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osc_plugin_dput/main.py b/osc_plugin_dput/main.py index 1ff6ed8..ac8a533 100644 --- a/osc_plugin_dput/main.py +++ b/osc_plugin_dput/main.py @@ -192,13 +192,18 @@ def do_dput(self, subcmd, opts, *args): superseded = set() retained = set() + # osc <1.6.1 doesn't automatically escape path members. + should_escape_filename = osc.core.makeurl('', ['+']) == '/+' + for f in remote_file_list.keys(): if f.endswith('.dsc'): u = osc.core.makeurl(conf.config['apiurl'], ['source', proj_name, package_name, - pathname2url(f)], + pathname2url(f) + if should_escape_filename + else f], query={}) remote_dsc = Dsc(osc.core.streamfile(u, bufsize='line')) -- GitLab