Issue1199

Title Can't use '%' in hgrc (eg url encoded username)
Priority bug Status resolved
Superseder Nosy List djc, mjc, mpm, shap, tonfa
Assigned To Topics

Created on 2008-06-25.00:59:48 by mjc, last changed 2008-10-09.08:35:48 by djc.

Files
File name Uploaded Type Edit Remove
configparser.py mpm, 2008-06-26.18:51:25 text/x-python
fix-http-at-username.diff mjc, 2008-06-25.00:59:48 text/plain
Messages
msg7351 (view) Author: djc Date: 2008-10-09.08:35:48
In main, resolving.
msg7174 (view) Author: tonfa Date: 2008-09-20.14:11:32
sorry I posted the wrong cset id, the correct one is: e51c0f41f271
msg7173 (view) Author: tonfa Date: 2008-09-20.14:09:27
Pushed to crew-stable (10a0bfa09ec4). Thanks.
msg6996 (view) Author: tonfa Date: 2008-09-08.12:15:41
@mjc:

to test it, just create a repo with a % in the name:
hg init foo%bar
hg clone foo%bar foobar
cd foobar
hg out
cat .hg/hgrc
msg6992 (view) Author: djc Date: 2008-09-08.11:21:49
I think it needs tests...
msg6984 (view) Author: tonfa Date: 2008-09-07.12:23:09
Is there something wrong with the proposed patch ?
msg6983 (view) Author: tonfa Date: 2008-09-07.12:12:07
Making title more accurate.
msg6425 (view) Author: mpm Date: 2008-06-26.18:51:25
Here's a prototype.
msg6417 (view) Author: djc Date: 2008-06-26.09:15:12
mpm: how is your new config parser work coming along? any news/half-baked impl?
msg6413 (view) Author: mpm Date: 2008-06-25.17:18:52
On Wed, 2008-06-25 at 09:17 -0400, Jonathan S. Shapiro wrote:
> On Wed, 2008-06-25 at 00:59 +0000, Michael Cahill wrote:
> > Our group has email addresses as https usernames, so they contain '@'...
> 
> I believe that this usage does not constitute a well-formed https URL.
> The traditional solution to this sort of "@ within @" problem would be
> to use something like:
> 
>   http://mjc%example.com@hg.example.com/
> 
> but of course '%' must be escaped.
> 
> In any case, we should check the well-formedness issue before accepting
> any patch to support this behavior. If the URL you want to use is
> malformed, hg should NOT (in my opinion) support it.
> 
> My concern is mainly that URLs are badly underspecified, which makes
> parsers for them crufty things already. Gunking up that code further to
> support malformed cases (if this is one) doesn't seem like a good idea.

On the other hand, all the URL parsing logic in hg is working for them
already. What's not working is our config file parser which has stupid
ideas about what % means.
msg6405 (view) Author: shap Date: 2008-06-25.14:14:36
On Wed, 2008-06-25 at 00:59 +0000, Michael Cahill wrote:
> Our group has email addresses as https usernames, so they contain '@'...

I believe that this usage does not constitute a well-formed https URL.
The traditional solution to this sort of "@ within @" problem would be
to use something like:

  http://mjc%example.com@hg.example.com/

but of course '%' must be escaped.

In any case, we should check the well-formedness issue before accepting
any patch to support this behavior. If the URL you want to use is
malformed, hg should NOT (in my opinion) support it.

My concern is mainly that URLs are badly underspecified, which makes
parsers for them crufty things already. Gunking up that code further to
support malformed cases (if this is one) doesn't seem like a good idea.

shap
msg6401 (view) Author: mjc Date: 2008-06-25.00:59:48
Our group has email addresses as https usernames, so they contain '@'.  This 
leads to commands like:
  hg clone http://mjc%40example.com@hg.example.com/repo/...

The clone works fine, but it puts the URL into .hgrc verbatim, which leads to 
the following stack trace when running hg in the working directory:

  File ".../site-packages/mercurial/ui.py", line 166, in readconfig
    self.fixconfig(root=root)
  File ".../site-packages/mercurial/ui.py", line 207, in fixconfig
    pathsitems = cdata.items('paths')
  File ".../python2.5/ConfigParser.py", line 557, in items
    for option in options]
  File ".../site-packages/mercurial/util.py", line 137, in _interpolate
    option, rawval, vars)
  File ".../python2.5/ConfigParser.py", line 593, in _interpolate
    self._interpolate_some(option, L, rawval, section, vars, 1)
  File ".../python2.5/ConfigParser.py", line 634, in _interpolate_some
    "'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', 
found: '%40example.com@hg.example.com/repo'

The same would happen for any URL-encoded username.  Suggested fix attached.
History
Date User Action Args
2008-10-09 08:35:48djcsetstatus: testing -> resolved
nosy: mpm, tonfa, shap, djc, mjc
messages: + msg7351
2008-09-20 14:15:13tonfasetstatus: chatting -> testing
nosy: mpm, tonfa, shap, djc, mjc
2008-09-20 14:11:32tonfasetnosy: mpm, tonfa, shap, djc, mjc
messages: + msg7174
2008-09-20 14:09:27tonfasetnosy: mpm, tonfa, shap, djc, mjc
messages: + msg7173
2008-09-08 12:15:41tonfasetnosy: mpm, tonfa, shap, djc, mjc
messages: + msg6996
2008-09-08 11:21:49djcsetnosy: mpm, tonfa, shap, djc, mjc
messages: + msg6992
2008-09-07 12:23:09tonfasetnosy: mpm, tonfa, shap, djc, mjc
messages: + msg6984
2008-09-07 12:12:09tonfasetnosy: + tonfa
messages: + msg6983
title: hg clone with '@' in http username -> Can't use '%' in hgrc (eg url encoded username)
2008-06-26 18:51:25mpmsetfiles: + configparser.py
nosy: mpm, shap, djc, mjc
messages: + msg6425
2008-06-26 09:15:13djcsetnosy: + djc
messages: + msg6417
2008-06-25 17:18:54mpmsetnosy: + mpm
messages: + msg6413
2008-06-25 14:14:36shapsetstatus: unread -> chatting
nosy: + shap
messages: + msg6405
2008-06-25 00:59:48mjccreate