diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-10-27 17:13:33 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-10-27 17:13:33 (GMT) |
commit | ff9e7abac8df84480bcfd7e3ce3a3dd912e69537 (patch) | |
tree | 82192ea2f35298639466ec5e05a28c72f33961bc /Lib/urllib2.py | |
parent | 7d1d540cc371e7c6ebfb3bc1c99699e5dcbdafe5 (diff) | |
download | cpython-ff9e7abac8df84480bcfd7e3ce3a3dd912e69537.zip cpython-ff9e7abac8df84480bcfd7e3ce3a3dd912e69537.tar.gz cpython-ff9e7abac8df84480bcfd7e3ce3a3dd912e69537.tar.bz2 |
[Patch #1574068 by Scott Dial] urllib and urllib2 were using
base64.encodestring() for encoding authentication data.
encodestring() can include newlines for very long input, which
produced broken HTTP headers.
2.4 backport candidate, probably.
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r-- | Lib/urllib2.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 3459f0d..890d3d4 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -674,7 +674,7 @@ class ProxyHandler(BaseHandler): proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) - creds = base64.encodestring(user_pass).strip() + creds = base64.b64encode(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) @@ -798,7 +798,7 @@ class AbstractBasicAuthHandler: user, pw = self.passwd.find_user_password(realm, host) if pw is not None: raw = "%s:%s" % (user, pw) - auth = 'Basic %s' % base64.encodestring(raw).strip() + auth = 'Basic %s' % base64.b64encode(raw).strip() if req.headers.get(self.auth_header, None) == auth: return None req.add_header(self.auth_header, auth) |