[Yum-devel] [PATCH] quote 'proxy_username' and 'proxy_password'. BZ 770117

Zdeněk Pavlas zpavlas at redhat.com
Tue Jan 10 17:10:44 UTC 2012


HTTP/FTP client has to parse the proxy user/pass from
proxy url, which uses ':' and '@' as delimiters.  Such
characters have to be quoted.  Quoting uses '%' so we
have to quote it as well.

An option is to use module urllib or urllib2, but yum
seems to try not to depend on these.
---
 yum/yumRepo.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 9988cd0..f26519d 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -445,13 +445,15 @@ class YumRepository(Repository, config.RepoConf):
                     proxy_rest = ''
                 else:
                     proxy_rest = proxy_parsed[2] + '?' + proxy_parsed[3]
-                proxy_string = '%s://%s@%s%s' % (proxy_proto,
-                        self.proxy_username, proxy_host, proxy_rest)
 
+                # BZ 770117: at least '%:@' have to be quoted
+                quote = lambda s: s.replace('%', '%25').replace(':', '%3A').replace('@', '%40')
+                auth = quote(self.proxy_username)
                 if self.proxy_password not in empty:
-                    proxy_string = '%s://%s:%s@%s%s' % (proxy_proto,
-                              self.proxy_username, self.proxy_password,
-                              proxy_host, proxy_rest)
+                    auth += ':' + quote(self.proxy_password)
+
+                proxy_string = '%s://%s@%s%s' % (proxy_proto,
+                          auth, proxy_host, proxy_rest)
 
         if proxy_string is not None:
             self._proxy_dict['http'] = proxy_string
-- 
1.7.4.4



More information about the Yum-devel mailing list