Bug#500560: [patch] proxy auth percent encoding
Tags: patch
Package: apt
Version: 0.7.25.3
Here is a patch proposed to Ubuntu
(https://bugs.edge.launchpad.net/ubuntu/+source/gnome-terminal/+bug/130289)
It does the following things:
- in QuoteString: escape '%'
- unescape proxy credentials
credentials need to be percent encoded in apt.conf (RFC3986)
=== modified file 'apt-pkg/contrib/strutl.cc'
--- apt-pkg/contrib/strutl.cc 2010-03-08 16:46:43 +0000
+++ apt-pkg/contrib/strutl.cc 2010-03-27 00:05:30 +0000
@@ -273,7 +273,7 @@
for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
{
if (strchr(Bad,*I) != 0 || isprint(*I) == 0 ||
- *I <= 0x20 || *I >= 0x7F)
+ *I <= 0x20 || *I >= 0x7F || *I == 0x25)
{
char Buf[10];
sprintf(Buf,"%%%02x",(int)*I);
@@ -293,7 +293,8 @@
string Res;
for (string::const_iterator I = Str.begin(); I != Str.end(); I++)
{
- if (*I == '%' && I + 2 < Str.end())
+ if (*I == '%' && I + 2 < Str.end() &&
+ isxdigit(int(*(I+1))) && isxdigit(int(*(I+2))))
{
char Tmp[3];
Tmp[0] = I[1];
@@ -1216,10 +1217,11 @@
}
else
{
+ // username and password must be encoded (RFC2396)
Host.assign(At+1,SingleSlash);
- User.assign(FirstColon,SecondColon);
+ User.assign(DeQuoteString(string(FirstColon,SecondColon)));
if (SecondColon < At)
- Password.assign(SecondColon+1,At);
+ Password.assign(DeQuoteString(string(SecondColon+1,At)));
}
// Now we parse the RFC 2732 [] hostnames.
Reply to: