]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bump exposed __version__ to 1.4.
authorGuido van Rossum <guido@python.org>
Mon, 26 Aug 1996 18:09:59 +0000 (18:09 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 26 Aug 1996 18:09:59 +0000 (18:09 +0000)
Correctly handle a URL containing user:password@host when using a proxy.

Lib/urllib.py

index f1756e2dfe1405e97eebab02f8701a54a06a99f9..621785f688cde4b5b5cb203d4e2169d0948b19f3 100644 (file)
@@ -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))