Blame SOURCES/0001-Pass-whole-URL-in-relativeUrl-to-PackageTarget-for-R.patch

59c9d3
From 5e082d74b73bf1b3565cfd72a3e1ba7a45a00a8b Mon Sep 17 00:00:00 2001
59c9d3
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
59c9d3
Date: Wed, 7 Sep 2022 14:40:32 +0200
59c9d3
Subject: [PATCH 1/2] Pass whole URL in relativeUrl to PackageTarget for RPM
59c9d3
 URL download
59c9d3
59c9d3
The PackageTarget supports baseUrl and relativeUrl on the API, but then
59c9d3
the relativeUrl is just a path fragment with no definition on whether it
59c9d3
should be encoded. It's being passed unencoded paths from other places,
59c9d3
and so there's a conditional encode (only if not full URL) in libdnf.
59c9d3
59c9d3
But full URLs are actually supported in relativeUrl (in that case
59c9d3
baseUrl should be empty) and in that case the URL is expected to be
59c9d3
encoded and is not encoded for the second time.
59c9d3
59c9d3
Hence, pass the full URL to relativeUrl instead of splitting it. We also
59c9d3
need to decode the file name we store, as on the filesystem the RPM file
59c9d3
name is also decoded.
59c9d3
59c9d3
= changelog =
59c9d3
msg: Don't double-encode RPM URLs passed on CLI
59c9d3
type: bugfix
59c9d3
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103015
59c9d3
---
59c9d3
 dnf/repo.py | 7 ++++---
59c9d3
 1 file changed, 4 insertions(+), 3 deletions(-)
59c9d3
59c9d3
diff --git a/dnf/repo.py b/dnf/repo.py
59c9d3
index ec1a2537..86fb2bf4 100644
59c9d3
--- a/dnf/repo.py
59c9d3
+++ b/dnf/repo.py
59c9d3
@@ -47,6 +47,7 @@ import string
59c9d3
 import sys
59c9d3
 import time
59c9d3
 import traceback
59c9d3
+import urllib
59c9d3
 
59c9d3
 _PACKAGES_RELATIVE_DIR = "packages"
59c9d3
 _MIRRORLIST_FILENAME = "mirrorlist"
59c9d3
@@ -295,7 +296,7 @@ class RemoteRPMPayload(PackagePayload):
59c9d3
         self.local_path = os.path.join(self.pkgdir, self.__str__().lstrip("/"))
59c9d3
 
59c9d3
     def __str__(self):
59c9d3
-        return os.path.basename(self.remote_location)
59c9d3
+        return os.path.basename(urllib.parse.unquote(self.remote_location))
59c9d3
 
59c9d3
     def _progress_cb(self, cbdata, total, done):
59c9d3
         self.remote_size = total
59c9d3
@@ -308,8 +309,8 @@ class RemoteRPMPayload(PackagePayload):
59c9d3
 
59c9d3
     def _librepo_target(self):
59c9d3
         return libdnf.repo.PackageTarget(
59c9d3
-            self.conf._config, os.path.basename(self.remote_location),
59c9d3
-            self.pkgdir, 0, None, 0, os.path.dirname(self.remote_location),
59c9d3
+            self.conf._config, self.remote_location,
59c9d3
+            self.pkgdir, 0, None, 0, None,
59c9d3
             True, 0, 0, self.callbacks)
59c9d3
 
59c9d3
     @property
59c9d3
-- 
59c9d3
2.37.3
59c9d3