Skip to content

Commit

Permalink
Pass whole URL in relativeUrl to PackageTarget for RPM URL download
Browse files Browse the repository at this point in the history
The PackageTarget supports baseUrl and relativeUrl on the API, but then
the relativeUrl is just a path fragment with no definition on whether it
should be encoded. It's being passed unencoded paths from other places,
and so there's a conditional encode (only if not full URL) in libdnf.

But full URLs are actually supported in relativeUrl (in that case
baseUrl should be empty) and in that case the URL is expected to be
encoded and is not encoded for the second time.

Hence, pass the full URL to relativeUrl instead of splitting it. We also
need to decode the file name we store, as on the filesystem the RPM file
name is also decoded.

= changelog =
msg: Don't double-encode RPM URLs passed on CLI
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103015
  • Loading branch information
Lukáš Hrázký authored and jan-kolarik committed Sep 12, 2022
1 parent e50875b commit d7bfd19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dnf/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import sys
import time
import traceback
import urllib

_PACKAGES_RELATIVE_DIR = "packages"
_MIRRORLIST_FILENAME = "mirrorlist"
Expand Down Expand Up @@ -295,7 +296,7 @@ def __init__(self, remote_location, conf, progress):
self.local_path = os.path.join(self.pkgdir, self.__str__().lstrip("/"))

def __str__(self):
return os.path.basename(self.remote_location)
return os.path.basename(urllib.parse.unquote(self.remote_location))

def _progress_cb(self, cbdata, total, done):
self.remote_size = total
Expand All @@ -308,8 +309,8 @@ def _progress_cb(self, cbdata, total, done):

def _librepo_target(self):
return libdnf.repo.PackageTarget(
self.conf._config, os.path.basename(self.remote_location),
self.pkgdir, 0, None, 0, os.path.dirname(self.remote_location),
self.conf._config, self.remote_location,
self.pkgdir, 0, None, 0, None,
True, 0, 0, self.callbacks)

@property
Expand Down

0 comments on commit d7bfd19

Please sign in to comment.