Package: apt-cacher-ng
Version: 0.7.25-1
Severity: normal
Tags: upstream patch
Dear Maintainer,
I use apt-cacher-ng to cache debdelta files. These files are stored
with percent-encoded file names on the server. For example:
dict-wn_1%3a3.0-31_1%3a3.0-32_all.debdelta
When requesting this file, the URL must be escaped as:
http://debdeltas.debian.net/debian-deltas/pool/main/w/wordnet/dict-wn_1%253a3.0-31_1%253a3.0-32_all.debdelta
Unfortunately, this request fails when using apt-cacher-ng as a proxy.
Using other proxies, like polipo, works as expected. Although,
apt-cacher-ng will work when the percent character is escaped twice,
for example:
http://debdeltas.debian.net/debian-deltas/pool/main/w/wordnet/dict-wn_1%25253a3.0-31_1%25253a3.0-32_all.debdelta
This is the incorrect behaviour, however.
I have included a patch that fixes this problem.
-- Package-specific info:
-- System Information:
Debian Release: jessie/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.10-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages apt-cacher-ng depends on:
ii adduser 3.113+nmu3
ii debconf [debconf-2.0] 1.5.52
ii dpkg 1.17.6
ii init-system-helpers 1.14
ii libbz2-1.0 1.0.6-5
ii libc6 2.17-97
ii libgcc1 1:4.8.2-14
ii liblzma5 5.1.1alpha+20120614-2
ii libssl1.0.0 1.0.1f-1
ii libstdc++6 4.8.2-14
ii libwrap0 7.6.q-25
ii zlib1g 1:1.2.8.dfsg-1
Versions of packages apt-cacher-ng recommends:
ii avahi-daemon 0.6.31-4
ii ed 1.9-2
Versions of packages apt-cacher-ng suggests:
ii curl 7.35.0-1
ii doc-base 0.10.5
ii libfuse2 2.9.2-4
ii wget 1.15-1
-- Configuration Files:
/etc/apt-cacher-ng/acng.conf changed:
CacheDir: /var/cache/apt-cacher-ng
LogDir: /var/log/apt-cacher-ng
Port:3142
BindAddress: 192.168.0.1
Remap-debrep: file:deb_mirror*.gz file:deb_mirrors /debian ;
file:backends_debian # Debian Archives
Remap-uburep: file:ubuntu_mirrors security.ubuntu.com/ubuntu /ubuntu ;
file:backends_ubuntu # Ubuntu Archives
Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol #
Debian Volatile Archives
Remap-debmul: file:debmul_mirrors /debian-multimedia ; file:backends_debmul
Remap-medibuntu: file:medibuntu_mirrors /medibuntu ; file:backends_medibuntu
Remap-getdeb: file:getdeb_mirrors /getdeb ; file:backends_getdeb
Remap-mate: http://packages.mate-desktop.org/repo/
Remap-opera: http://deb.opera.com/opera/
Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin #
incomplete, please create this file or specify preferred mirrors here
Remap-sfnet: file:sfnet_mirrors http://downloads.sourceforge.net/ # ;
file:backends_sfnet # incomplete, please create this file or specify preferred
mirrors here
Remap-alxrep: file:archlx_mirrors /archlinux # ; file:backend_archlx # Arch
Linux
Remap-fedora: file:fedora_mirrors # Fedora Linux
Remap-epel: file:epel_mirrors # Fedora EPEL
Remap-slrep: file:sl_mirrors # Scientific Linux
Remap-gentoo: file:gentoo_mirrors.gz /gentoo ; file:backends_gentoo # Gentoo
Archives
Remap-debdeltas: file:debdeltas_mirrors
Remap-linuxmint: file:linuxmint_mirrors # ; file:backends_linuxmint
Remap-static/dropbox: file:dropbox_mirrors
Remap-static/openwrt: http://downloads.openwrt.org/
Remap-static/microsoft: file:microsoft_mirrors
Remap-static/windowsupdate: file:windowsupdate_mirrors
Remap-static/adobe: file:adobe_mirrors
Remap-static/apple: file:apple_mirrors
Remap-static/autopatcher: http://www.autopatcher.com/
Remap-static/playonlinux: http://repository.playonlinux.com/
Remap-static/avast: http://files.avast.com/
ReportPage: acng-report.html
ExTreshold: 4
VfilePattern =
(^|.*/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|custom\.gpg|mirrors.txt|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.(db|files|abs)(\.tar(\.gz|\.bz2|\.lzma|\.xz))?|metalink\?repo|.*prestodelta\.xml\.gz|repodata/.*\.(xml|sqlite)(\.gz|\.bz2|\.lzma|\.xz))$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*|^.*(\.vps|\.md5|\.exe|\.cab|\.msi|\.zip|\.bin|\.psf|\.7z|\.iso|\.msu|\.apf|\.pdf|\.swf|\.f4v|\.flv|\.xml|\.png|\.dae|\.jpg|\.css|\.js|\.gif|\.wof|\.apm)$
WfilePattern =
(^|.*/)(Release|InRelease|Release\.gpg|custom\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.(db|files|abs)(\.tar(\.gz|\.bz2|\.lzma|\.xz))?|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*|^static/.*
Debug:4
RecompBz2: 1
DontCache: carlitos 192.168.0.1
DirPerms: 02755
FilePerms: 00644
LocalDirs: acng-doc /usr/share/doc/apt-cacher-ng
PassThroughPattern: private-ppa\.launchpad\.net:443$
/etc/apt-cacher-ng/security.conf [Errno 13] Permission denied:
u'/etc/apt-cacher-ng/security.conf'
/etc/default/apt-cacher-ng changed:
umask 022
DAEMON_OPTS=" -c /etc/apt-cacher-ng "
-- debconf information:
apt-cacher-ng/bindaddress: keep
apt-cacher-ng/proxy: keep
apt-cacher-ng/port: keep
apt-cacher-ng/gentargetmode: No automated setup
apt-cacher-ng/cachedir: keep
>From 71ffcdd7e62e48e2869c6c161c5401ae980dfbc6 Mon Sep 17 00:00:00 2001
From: Carlos Maddela <[email protected]>
Date: Thu, 6 Feb 2014 03:32:22 +1100
Subject: handle percent-encoding of percent character
Description: Handle requests that require percent-encoding of the
percent character correctly.
Patch-Name: handle-percent-encoding-of-percent-character.patch
---
include/meta.h | 2 +-
source/dlcon.cc | 2 +-
source/job.cc | 2 +-
source/meta.cc | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/meta.h b/include/meta.h
index cc4a52d..665d093 100644
--- a/include/meta.h
+++ b/include/meta.h
@@ -162,7 +162,7 @@ bool ParseKeyValLine(const mstring & sIn, mstring & sOutKey, mstring & sOutVal);
class tHttpUrl
{
public:
- bool SetHttpUrl(cmstring &uri);
+ bool SetHttpUrl(cmstring &uri, bool unescape = true);
mstring ToURI(bool bEscaped) const;
mstring sHost, sPath, sUserPass;
bool bIsTransferlEncoded;
diff --git a/source/dlcon.cc b/source/dlcon.cc
index 86f836f..dc27746 100644
--- a/source/dlcon.cc
+++ b/source/dlcon.cc
@@ -134,7 +134,7 @@ struct tDlJob
mstring s;
for (const char *p = pNewUrl; *p; ++p)
{
- if (isspace((unsigned char) *p))
+ if (isspace((unsigned char) *p) || *p == '%')
{
s += "%";
s += BytesToHexString((uint8_t*) p, 1);
diff --git a/source/job.cc b/source/job.cc
index 16a0e0a..ac99407 100644
--- a/source/job.cc
+++ b/source/job.cc
@@ -526,7 +526,7 @@ void job::PrepareDownload() {
if (0==sReqPath.compare(0, 11, "apt-cacher/"))
sReqPath.erase(11);
- if(!tUrl.SetHttpUrl(sReqPath))
+ if(!tUrl.SetHttpUrl(sReqPath, false))
{
m_sMaintCmd="/";
return;
diff --git a/source/meta.cc b/source/meta.cc
index 6f5b138..8e139b2 100644
--- a/source/meta.cc
+++ b/source/meta.cc
@@ -194,7 +194,7 @@ bool ParseKeyValLine(const string & sIn, string & sOutKey, string & sOutVal)
}
-bool tHttpUrl::SetHttpUrl(cmstring &sUrlRaw)
+bool tHttpUrl::SetHttpUrl(cmstring &sUrlRaw, bool unescape)
{
sPort.clear();
sHost.clear();
@@ -205,7 +205,7 @@ bool tHttpUrl::SetHttpUrl(cmstring &sUrlRaw)
#endif
bIsTransferlEncoded=false;
- mstring url = UrlUnescape(sUrlRaw);
+ mstring url = unescape ? UrlUnescape(sUrlRaw) : sUrlRaw;
trimBack(url);
trimFront(url);