--- a/mercurial/util.py Sun Jul 31 22:12:13 2011 +0200
+++ b/mercurial/util.py Mon Aug 01 10:54:34 2011 -0500
@@ -1500,8 +1500,9 @@
self.path = path
+ # leave the query string escaped
for a in ('user', 'passwd', 'host', 'port',
- 'path', 'query', 'fragment'):
+ 'path', 'fragment'):
v = getattr(self, a)
if v is not None:
setattr(self, a, _urlunquote(v))
@@ -1522,6 +1523,10 @@
>>> str(url('http://user:pw@host:80/?foo#bar'))
'http://user:pw@host:80/?foo#bar'
+ >>> str(url('http://user:pw@host:80/?foo=bar&baz=42'))
+ 'http://user:pw@host:80/?foo=bar&baz=42'
+ >>> str(url('http://user:pw@host:80/?foo=bar%3dbaz'))
+ 'http://user:pw@host:80/?foo=bar%3dbaz'
>>> str(url('ssh://user:pw@[::1]:2200//home/joe#'))
'ssh://user:pw@[::1]:2200//home/joe#'
>>> str(url('http://localhost:80//'))
@@ -1570,9 +1575,13 @@
if self.host:
s += '/'
if self.path:
+ # TODO: similar to the query string, we should not unescape the
+ # path when we store it, the path might contain '%2f' = '/',
+ # which we should *not* escape.
s += urllib.quote(self.path, safe=self._safepchars)
if self.query:
- s += '?' + urllib.quote(self.query, safe=self._safepchars)
+ # we store the query in escaped form.
+ s += '?' + self.query
if self.fragment is not None:
s += '#' + urllib.quote(self.fragment, safe=self._safepchars)
return s