From 78c96370755a53a296183e83fb536df2890f9195 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 26 Aug 1996 18:09:59 +0000 Subject: [PATCH] Bump exposed __version__ to 1.4. Correctly handle a URL containing user:password@host when using a proxy. --- Lib/urllib.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Lib/urllib.py b/Lib/urllib.py index f1756e2dfe1..621785f688c 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -20,7 +20,7 @@ import regex import os -__version__ = '1.3' +__version__ = '1.4' # Helper for non-unix systems if os.name == 'mac': @@ -179,15 +179,18 @@ class URLopener: import httplib if type(url) is type(""): host, selector = splithost(url) + user_passwd, host = splituser(host) else: host, selector = url + urltype, rest = splittype(selector) + if string.lower(urltype) == 'http': + realhost, rest = splithost(rest) + user_passwd, realhost = splituser(realhost) + if user_passwd: + selector = "%s://%s%s" % (urltype, + realhost, rest) print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') - i = string.find(host, '@') - if i >= 0: - user_passwd, host = host[:i], host[i+1:] - else: - user_passwd = None if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd))