Show More
@@ -274,42 +274,6 b' def removeauth(u):' | |||||
274 | u.user = u.passwd = None |
|
274 | u.user = u.passwd = None | |
275 | return str(u) |
|
275 | return str(u) | |
276 |
|
276 | |||
277 | def netlocsplit(netloc): |
|
|||
278 | '''split [user[:passwd]@]host[:port] into 4-tuple.''' |
|
|||
279 |
|
||||
280 | a = netloc.find('@') |
|
|||
281 | if a == -1: |
|
|||
282 | user, passwd = None, None |
|
|||
283 | else: |
|
|||
284 | userpass, netloc = netloc[:a], netloc[a + 1:] |
|
|||
285 | c = userpass.find(':') |
|
|||
286 | if c == -1: |
|
|||
287 | user, passwd = urllib.unquote(userpass), None |
|
|||
288 | else: |
|
|||
289 | user = urllib.unquote(userpass[:c]) |
|
|||
290 | passwd = urllib.unquote(userpass[c + 1:]) |
|
|||
291 | c = netloc.find(':') |
|
|||
292 | if c == -1: |
|
|||
293 | host, port = netloc, None |
|
|||
294 | else: |
|
|||
295 | host, port = netloc[:c], netloc[c + 1:] |
|
|||
296 | return host, port, user, passwd |
|
|||
297 |
|
||||
298 | def netlocunsplit(host, port, user=None, passwd=None): |
|
|||
299 | '''turn host, port, user, passwd into [user[:passwd]@]host[:port].''' |
|
|||
300 | if port: |
|
|||
301 | hostport = host + ':' + port |
|
|||
302 | else: |
|
|||
303 | hostport = host |
|
|||
304 | if user: |
|
|||
305 | quote = lambda s: urllib.quote(s, safe='') |
|
|||
306 | if passwd: |
|
|||
307 | userpass = quote(user) + ':' + quote(passwd) |
|
|||
308 | else: |
|
|||
309 | userpass = quote(user) |
|
|||
310 | return userpass + '@' + hostport |
|
|||
311 | return hostport |
|
|||
312 |
|
||||
313 | def readauthforuri(ui, uri): |
|
277 | def readauthforuri(ui, uri): | |
314 | # Read configuration |
|
278 | # Read configuration | |
315 | config = dict() |
|
279 | config = dict() | |
@@ -342,44 +306,6 b' def readauthforuri(ui, uri):' | |||||
342 | bestauth = group, auth |
|
306 | bestauth = group, auth | |
343 | return bestauth |
|
307 | return bestauth | |
344 |
|
308 | |||
345 | _safe = ('abcdefghijklmnopqrstuvwxyz' |
|
|||
346 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
|
|||
347 | '0123456789' '_.-/') |
|
|||
348 | _safeset = None |
|
|||
349 | _hex = None |
|
|||
350 | def quotepath(path): |
|
|||
351 | '''quote the path part of a URL |
|
|||
352 |
|
||||
353 | This is similar to urllib.quote, but it also tries to avoid |
|
|||
354 | quoting things twice (inspired by wget): |
|
|||
355 |
|
||||
356 | >>> quotepath('abc def') |
|
|||
357 | 'abc%20def' |
|
|||
358 | >>> quotepath('abc%20def') |
|
|||
359 | 'abc%20def' |
|
|||
360 | >>> quotepath('abc%20 def') |
|
|||
361 | 'abc%20%20def' |
|
|||
362 | >>> quotepath('abc def%20') |
|
|||
363 | 'abc%20def%20' |
|
|||
364 | >>> quotepath('abc def%2') |
|
|||
365 | 'abc%20def%252' |
|
|||
366 | >>> quotepath('abc def%') |
|
|||
367 | 'abc%20def%25' |
|
|||
368 | ''' |
|
|||
369 | global _safeset, _hex |
|
|||
370 | if _safeset is None: |
|
|||
371 | _safeset = set(_safe) |
|
|||
372 | _hex = set('abcdefABCDEF0123456789') |
|
|||
373 | l = list(path) |
|
|||
374 | for i in xrange(len(l)): |
|
|||
375 | c = l[i] |
|
|||
376 | if (c == '%' and i + 2 < len(l) and |
|
|||
377 | l[i + 1] in _hex and l[i + 2] in _hex): |
|
|||
378 | pass |
|
|||
379 | elif c not in _safeset: |
|
|||
380 | l[i] = '%%%02X' % ord(c) |
|
|||
381 | return ''.join(l) |
|
|||
382 |
|
||||
383 | class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): |
|
309 | class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): | |
384 | def __init__(self, ui): |
|
310 | def __init__(self, ui): | |
385 | urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
|
311 | urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
General Comments 0
You need to be logged in to leave comments.
Login now