mirror of
https://github.com/python/cpython.git
synced 2025-08-16 06:40:56 +00:00
- Issue #13642: Unquote before b64encoding user:password during Basic
Authentication. Patch contributed by Joonas Kuorilehto and Michele Orrù.
This commit is contained in:
parent
a0ff91cac0
commit
bcd833f30f
3 changed files with 60 additions and 8 deletions
|
@ -27,6 +27,8 @@ import socket
|
|||
import os
|
||||
import time
|
||||
import sys
|
||||
import base64
|
||||
|
||||
from urlparse import urljoin as basejoin
|
||||
|
||||
__all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve",
|
||||
|
@ -318,13 +320,13 @@ class URLopener:
|
|||
if not host: raise IOError, ('http error', 'no host given')
|
||||
|
||||
if proxy_passwd:
|
||||
import base64
|
||||
proxy_passwd = unquote(proxy_passwd)
|
||||
proxy_auth = base64.b64encode(proxy_passwd).strip()
|
||||
else:
|
||||
proxy_auth = None
|
||||
|
||||
if user_passwd:
|
||||
import base64
|
||||
user_passwd = unquote(user_passwd)
|
||||
auth = base64.b64encode(user_passwd).strip()
|
||||
else:
|
||||
auth = None
|
||||
|
@ -408,12 +410,12 @@ class URLopener:
|
|||
#print "proxy via https:", host, selector
|
||||
if not host: raise IOError, ('https error', 'no host given')
|
||||
if proxy_passwd:
|
||||
import base64
|
||||
proxy_passwd = unquote(proxy_passwd)
|
||||
proxy_auth = base64.b64encode(proxy_passwd).strip()
|
||||
else:
|
||||
proxy_auth = None
|
||||
if user_passwd:
|
||||
import base64
|
||||
user_passwd = unquote(user_passwd)
|
||||
auth = base64.b64encode(user_passwd).strip()
|
||||
else:
|
||||
auth = None
|
||||
|
@ -589,7 +591,6 @@ class URLopener:
|
|||
time.gmtime(time.time())))
|
||||
msg.append('Content-type: %s' % type)
|
||||
if encoding == 'base64':
|
||||
import base64
|
||||
data = base64.decodestring(data)
|
||||
else:
|
||||
data = unquote(data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue