summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-07-10 20:19:31 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-12-18 20:45:35 +0100
commita5859bafdaa6bcf12934d0fb1715a5940965e13a (patch)
treee0cb170d0a4f8caff89c2402bf24e6951b716360
parent97d6c3b2d05fe0d965657197adf56cc78f9edf81 (diff)
Don't re-encode encoded URIs in pkgAcqFile
This commit potentially breaks code feeding apt an encoded URI using a method which does not get URIs send encoded. The webserverconfig requests in our tests are an example for this – but they only worked before if the server was expecting a double encoding as that was what was happening to an encoded URI: so unlikely to work as expected in practice. Now with the new methods we can drop this double encoding and rely on the URI being passed properly (and without modification) between the layers so that passing in encoded URIs should now work correctly.
-rw-r--r--apt-pkg/acquire-item.cc3
-rw-r--r--test/interactive-helper/aptwebserver.cc2
2 files changed, 3 insertions, 2 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 34528f2ec..a4ad6b854 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -3860,7 +3860,8 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *const Owner, string const &URI, HashStringLis
DestFile = flNotDir(URI);
::URI url{URI};
- url.Path = pkgAcquire::URIEncode(url.Path);
+ if (url.Path.find(' ') != std::string::npos || url.Path.find('%') == std::string::npos)
+ url.Path = pkgAcquire::URIEncode(url.Path);
// Create the item
Desc.URI = std::string(url);
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 57d215a65..58ba54f84 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -630,7 +630,7 @@ static bool handleOnTheFlyReconfiguration(std::ostream &log, int const client,/*
size_t const pcount = EncodedParts.size();
std::vector<std::string> parts(pcount);
for (size_t i = 0; i < pcount; ++i)
- parts[i] = DeQuoteString(DeQuoteString(EncodedParts[i]));
+ parts[i] = DeQuoteString(EncodedParts[i]);
if (pcount == 4 && parts[1] == "set")
{
_config->Set(parts[2], parts[3]);