summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2021-06-04 13:06:34 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2021-06-04 16:43:41 +0200
commit149b23c2b9697bc262c0af1934c7a3f6114d903f (patch)
tree4d785c2b812e1284d1317e30ebd6df18fbb959cd /apt-pkg
parentaeae140b11220c8ca3692ef690bc51578f197992 (diff)
URI encode Filename field of Packages files (again)
Keeping URIs encoded in the acquire system depends on having them encoded in the first place. While many other places got the encoding 2 out of 3 ArchiveURI implementations were missed which are in practice responsible for nearly all of the URI building, just that index filename do not contain characters to escape and the Filename fields in Packages files usually aren't. Usually. Except if you happen to have e.g. an epoch featuring package with the colon encoded in the filename. On the upside, in most repositories the epoch isn't part of the filename. Reported-By: Johannes 'josch' Schauer on IRC References: e6c55283d235aa9404395d30f2db891f36995c49
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc12
-rw-r--r--apt-pkg/indexfile.cc5
2 files changed, 9 insertions, 8 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 225c4304a..d6ffaf34d 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -3853,16 +3853,16 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *const Owner, string const &URI, HashStringLis
const string &DestDir, const string &DestFilename,
bool const IsIndexFile) : Item(Owner), d(NULL), IsIndexFile(IsIndexFile), ExpectedHashes(Hashes)
{
+ ::URI url{URI};
+ if (url.Path.find(' ') != std::string::npos || url.Path.find('%') == std::string::npos)
+ url.Path = pkgAcquire::URIEncode(url.Path);
+
if(!DestFilename.empty())
DestFile = DestFilename;
else if(!DestDir.empty())
- DestFile = DestDir + "/" + flNotDir(URI);
+ DestFile = DestDir + "/" + DeQuoteString(flNotDir(url.Path));
else
- DestFile = flNotDir(URI);
-
- ::URI url{URI};
- if (url.Path.find(' ') != std::string::npos || url.Path.find('%') == std::string::npos)
- url.Path = pkgAcquire::URIEncode(url.Path);
+ DestFile = DeQuoteString(flNotDir(url.Path));
// Create the item
Desc.URI = std::string(url);
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index ef3486ab8..f13b52940 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -9,6 +9,7 @@
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/acquire.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/deblistparser.h>
@@ -174,7 +175,7 @@ pkgDebianIndexTargetFile::pkgDebianIndexTargetFile(IndexTarget const &Target, bo
/*}}}*/
std::string pkgDebianIndexTargetFile::ArchiveURI(std::string const &File) const/*{{{*/
{
- return Target.Option(IndexTarget::REPO_URI) + File;
+ return Target.Option(IndexTarget::REPO_URI) + pkgAcquire::URIEncode(File);
}
/*}}}*/
std::string pkgDebianIndexTargetFile::Describe(bool const Short) const /*{{{*/
@@ -281,7 +282,7 @@ std::string pkgDebianIndexRealFile::Describe(bool const /*Short*/) const/*{{{*/
/*}}}*/
std::string pkgDebianIndexRealFile::ArchiveURI(std::string const &/*File*/) const/*{{{*/
{
- return "file:" + File;
+ return "file:" + pkgAcquire::URIEncode(File);
}
/*}}}*/
std::string pkgDebianIndexRealFile::IndexFileName() const /*{{{*/