Show More
@@ -1565,7 +1565,9 b' class url(object):' | |||||
1565 | self.user, self.passwd = user, passwd |
|
1565 | self.user, self.passwd = user, passwd | |
1566 | if not self.user: |
|
1566 | if not self.user: | |
1567 | return (s, None) |
|
1567 | return (s, None) | |
1568 | return (s, (None, (str(self), self.host), |
|
1568 | # authinfo[1] is passed to urllib2 password manager, and its URIs | |
|
1569 | # must not contain credentials. | |||
|
1570 | return (s, (None, (s, self.host), | |||
1569 | self.user, self.passwd or '')) |
|
1571 | self.user, self.passwd or '')) | |
1570 |
|
1572 | |||
1571 | def isabs(self): |
|
1573 | def isabs(self): |
@@ -1,4 +1,5 b'' | |||||
1 | from mercurial import demandimport; demandimport.enable() |
|
1 | from mercurial import demandimport; demandimport.enable() | |
|
2 | import urllib2 | |||
2 | from mercurial import ui, util |
|
3 | from mercurial import ui, util | |
3 | from mercurial import url |
|
4 | from mercurial import url | |
4 | from mercurial.error import Abort |
|
5 | from mercurial.error import Abort | |
@@ -95,3 +96,12 b" test({'x.prefix': 'http://example.org/fo" | |||||
95 | 'y.username': 'y', |
|
96 | 'y.username': 'y', | |
96 | 'y.password': 'ypassword'}, |
|
97 | 'y.password': 'ypassword'}, | |
97 | urls=['http://y@example.org/foo/bar']) |
|
98 | urls=['http://y@example.org/foo/bar']) | |
|
99 | ||||
|
100 | def testauthinfo(fullurl, authurl): | |||
|
101 | print 'URIs:', fullurl, authurl | |||
|
102 | pm = urllib2.HTTPPasswordMgrWithDefaultRealm() | |||
|
103 | pm.add_password(*util.url(fullurl).authinfo()[1]) | |||
|
104 | print pm.find_user_password('test', authurl) | |||
|
105 | ||||
|
106 | print '\n*** Test urllib2 and util.url\n' | |||
|
107 | testauthinfo('http://user@example.com:8080/foo', 'http://example.com:8080/foo') |
@@ -189,3 +189,8 b' URI: http://y@example.org/foo' | |||||
189 | CFG: {x.password: xpassword, x.prefix: http://example.org/foo/bar, x.username: None, y.password: ypassword, y.prefix: http://example.org/foo, y.username: y} |
|
189 | CFG: {x.password: xpassword, x.prefix: http://example.org/foo/bar, x.username: None, y.password: ypassword, y.prefix: http://example.org/foo, y.username: y} | |
190 | URI: http://y@example.org/foo/bar |
|
190 | URI: http://y@example.org/foo/bar | |
191 | ('y', 'xpassword') |
|
191 | ('y', 'xpassword') | |
|
192 | ||||
|
193 | *** Test urllib2 and util.url | |||
|
194 | ||||
|
195 | URIs: http://user@example.com:8080/foo http://example.com:8080/foo | |||
|
196 | ('user', '') |
General Comments 0
You need to be logged in to leave comments.
Login now