> > '%25').replace(':', '%3A').replace('@', '%40')
> 
>  Just use urllib.quote().

OK.
 
>  Rest looks fine. ACK.

If someone has made the suggested workaround and already
quoted the username in config, this would break again,
so I've made more changes:

- Avoid (a very specific case of) double quoting.
- Got rid of that clumsy urlsplit() usage

commit 53e842bba6c5469642c91208a338425a4d267fbb
Author: Zdeněk Pavlas <[email protected]>
Date:   Wed Jan 11 10:22:11 2012 +0100

    Quote 'proxy_username' and 'proxy_password'. BZ 770117
    
    Quote the username and password when pasting into
    a proxy url because ':' and '@' have special meaning.
    Check for already quoted 'user@domain' usernames.

diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 9988cd0..d63d711 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -20,6 +20,7 @@ import time
 import types
 import urlparse
 urlparse.uses_fragment.append("media")
+import urllib
 
 import Errors
 from urlgrabber.grabber import URLGrabber
@@ -436,22 +437,16 @@ class YumRepository(Repository, config.RepoConf):
         if self.proxy not in empty:
             proxy_string = '%s' % self.proxy
             if self.proxy_username not in empty:
-                proxy_parsed = urlparse.urlsplit(self.proxy, allow_fragments=0)
-                proxy_proto = proxy_parsed[0]
-                proxy_host = proxy_parsed[1]
-                # http://foo:123 == ('http', 'foo:123', '', '', '')
-                # don't turn that into: http://foo:123? - bug#328121
-                if proxy_parsed[2] == '':
-                    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)
 
+                auth = self.proxy_username
+                if not re.match('\w+%40[\w\.]+$', auth):
+                    # unless already quoted 'user@domain'
+                    auth = urllib.quote(auth)
                 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 += ':' + urllib.quote(self.proxy_password)
+
+                proto, rest = re.match('(\w+://)(.+)', proxy_string).groups()
+                proxy_string = '%s%s@%s' % (proto, auth, rest)
 
         if proxy_string is not None:
             self._proxy_dict['http'] = proxy_string
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to