Issue1998

Title http_proxy.passwd is not correctly handling '/'
Priority bug Status testing
Superseder Nosy List brodie, carbonnq, tonfa
Assigned To Topics patch, surprise, ui

Created on 2010-01-26.22:49:01 by carbonnq, last changed 2010-02-15.21:59:30 by tonfa.

Messages
msg11746 (view) Author: tonfa Date: 2010-02-15.21:59:30
changeset:   10484:cadd7e076b69
branch:      stable
tag:         tip
user:        Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date:        Mon Feb 15 22:39:36 2010 +0100
summary:     url: correctly quote '/' in user and password embedded in urls
msg11740 (view) Author: tonfa Date: 2010-02-15.21:12:29
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -180,6 +180,7 @@
             if not proxyuser:
                 proxyuser = ui.config("http_proxy", "user")
                 proxypasswd = ui.config("http_proxy", "passwd")
+            proxypasswd = urllib.quote(proxypasswd or '', safe='')
 
             # see if we should use a proxy for this url
             no_list = ["localhost", "127.0.0.1"]
@@ -196,7 +197,7 @@
 
             proxyurl = urlparse.urlunsplit((
                 proxyscheme, netlocunsplit(proxyhost, proxyport,
-                                                proxyuser, proxypasswd or 
''),
+                                                proxyuser, proxypasswd),
                 proxypath, proxyquery, proxyfrag))
             proxies = {'http': proxyurl, 'https': proxyurl}
             ui.debug('proxying through http://%s:%s\n' %
msg11514 (view) Author: carbonnq Date: 2010-01-26.22:49:01
If one has this config file

[http_proxy]
host=proxy.here.com
user=john
passwd=pass/word

the '/' is not correctly handled since the password string is retrieved as
is from the config file and put in a 'url' describing the proxy settings,
then given to urllib.
In order to have a working config file we must write

[http_proxy]
host=proxy.here.com
user=john
passwd=pass%2Fword

which is far from instinctive (and not documented).

A solution is to replace every '/' by '%2F' in the password string before
giving it to the urllib.
History
Date User Action Args
2010-02-15 21:59:30tonfasetstatus: in-progress -> testing
messages: + msg11746
2010-02-15 21:12:38tonfasetstatus: chatting -> in-progress
topic: + patch
2010-02-15 21:12:29tonfasetstatus: unread -> chatting
messages: + msg11740
2010-02-14 22:53:24brodiesetnosy: + brodie
2010-02-14 11:43:13tonfasettopic: + ui, surprise
2010-02-14 11:42:51tonfasetnosy: + tonfa
2010-01-26 22:49:01carbonnqcreate