Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c5c5a145
Kaydet (Commit)
c5c5a145
authored
Ock 14, 2012
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue #13642: Unquote before b64encoding user:password during Basic Authentication.
üst
9bbcb254
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
test_urllib.py
Lib/test/test_urllib.py
+31
-2
request.py
Lib/urllib/request.py
+2
-3
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib.py
Dosyayı görüntüle @
c5c5a145
...
@@ -12,6 +12,8 @@ import os
...
@@ -12,6 +12,8 @@ import os
import
sys
import
sys
import
tempfile
import
tempfile
from
base64
import
b64encode
def
hexescape
(
char
):
def
hexescape
(
char
):
"""Escape char as RFC 2396 specifies"""
"""Escape char as RFC 2396 specifies"""
hex_repr
=
hex
(
ord
(
char
))[
2
:]
.
upper
()
hex_repr
=
hex
(
ord
(
char
))[
2
:]
.
upper
()
...
@@ -42,8 +44,8 @@ class FakeHTTPMixin(object):
...
@@ -42,8 +44,8 @@ class FakeHTTPMixin(object):
class
FakeSocket
(
io
.
BytesIO
):
class
FakeSocket
(
io
.
BytesIO
):
io_refs
=
1
io_refs
=
1
def
sendall
(
self
,
str
):
def
sendall
(
self
,
data
):
pass
FakeHTTPConnection
.
buf
=
data
def
makefile
(
self
,
*
args
,
**
kwds
):
def
makefile
(
self
,
*
args
,
**
kwds
):
self
.
io_refs
+=
1
self
.
io_refs
+=
1
...
@@ -65,8 +67,13 @@ class FakeHTTPMixin(object):
...
@@ -65,8 +67,13 @@ class FakeHTTPMixin(object):
io
.
BytesIO
.
close
(
self
)
io
.
BytesIO
.
close
(
self
)
class
FakeHTTPConnection
(
http
.
client
.
HTTPConnection
):
class
FakeHTTPConnection
(
http
.
client
.
HTTPConnection
):
# buffer to store data for verification in urlopen tests.
buf
=
None
def
connect
(
self
):
def
connect
(
self
):
self
.
sock
=
FakeSocket
(
fakedata
)
self
.
sock
=
FakeSocket
(
fakedata
)
self
.
_connection_class
=
http
.
client
.
HTTPConnection
self
.
_connection_class
=
http
.
client
.
HTTPConnection
http
.
client
.
HTTPConnection
=
FakeHTTPConnection
http
.
client
.
HTTPConnection
=
FakeHTTPConnection
...
@@ -268,6 +275,25 @@ Content-Type: text/html; charset=iso-8859-1
...
@@ -268,6 +275,25 @@ Content-Type: text/html; charset=iso-8859-1
finally
:
finally
:
self
.
unfakehttp
()
self
.
unfakehttp
()
def
test_userpass_inurl_w_spaces
(
self
):
self
.
fakehttp
(
b
"HTTP/1.0 200 OK
\r\n\r\n
Hello!"
)
try
:
userpass
=
"a b:c d"
url
=
"http://{}@python.org/"
.
format
(
userpass
)
fakehttp_wrapper
=
http
.
client
.
HTTPConnection
authorization
=
(
"Authorization: Basic
%
s
\r\n
"
%
b64encode
(
userpass
.
encode
(
"ASCII"
))
.
decode
(
"ASCII"
))
fp
=
urlopen
(
url
)
# The authorization header must be in place
self
.
assertIn
(
authorization
,
fakehttp_wrapper
.
buf
.
decode
(
"UTF-8"
))
self
.
assertEqual
(
fp
.
readline
(),
b
"Hello!"
)
self
.
assertEqual
(
fp
.
readline
(),
b
""
)
# the spaces are quoted in URL so no match
self
.
assertNotEqual
(
fp
.
geturl
(),
url
)
self
.
assertEqual
(
fp
.
getcode
(),
200
)
finally
:
self
.
unfakehttp
()
class
urlretrieve_FileTests
(
unittest
.
TestCase
):
class
urlretrieve_FileTests
(
unittest
.
TestCase
):
"""Test urllib.urlretrieve() on local files"""
"""Test urllib.urlretrieve() on local files"""
...
@@ -1111,6 +1137,9 @@ class Utility_Tests(unittest.TestCase):
...
@@ -1111,6 +1137,9 @@ class Utility_Tests(unittest.TestCase):
self
.
assertEqual
((
'user'
,
'a
\f
b'
),
urllib
.
parse
.
splitpasswd
(
'user:a
\f
b'
))
self
.
assertEqual
((
'user'
,
'a
\f
b'
),
urllib
.
parse
.
splitpasswd
(
'user:a
\f
b'
))
self
.
assertEqual
((
'user'
,
'a
\v
b'
),
urllib
.
parse
.
splitpasswd
(
'user:a
\v
b'
))
self
.
assertEqual
((
'user'
,
'a
\v
b'
),
urllib
.
parse
.
splitpasswd
(
'user:a
\v
b'
))
self
.
assertEqual
((
'user'
,
'a:b'
),
urllib
.
parse
.
splitpasswd
(
'user:a:b'
))
self
.
assertEqual
((
'user'
,
'a:b'
),
urllib
.
parse
.
splitpasswd
(
'user:a:b'
))
self
.
assertEqual
((
'user'
,
'a b'
),
urllib
.
parse
.
splitpasswd
(
'user:a b'
))
self
.
assertEqual
((
'user 2'
,
'ab'
),
urllib
.
parse
.
splitpasswd
(
'user 2:ab'
))
self
.
assertEqual
((
'user+1'
,
'a+b'
),
urllib
.
parse
.
splitpasswd
(
'user+1:a+b'
))
def
test_thishost
(
self
):
def
test_thishost
(
self
):
"""Test the urllib.request.thishost utility function returns a tuple"""
"""Test the urllib.request.thishost utility function returns a tuple"""
...
...
Lib/urllib/request.py
Dosyayı görüntüle @
c5c5a145
...
@@ -1661,13 +1661,13 @@ class URLopener:
...
@@ -1661,13 +1661,13 @@ class URLopener:
if
not
host
:
raise
IOError
(
'http error'
,
'no host given'
)
if
not
host
:
raise
IOError
(
'http error'
,
'no host given'
)
if
proxy_passwd
:
if
proxy_passwd
:
import
base64
proxy_passwd
=
unquote
(
proxy_passwd
)
proxy_auth
=
base64
.
b64encode
(
proxy_passwd
.
encode
())
.
decode
(
'ascii'
)
proxy_auth
=
base64
.
b64encode
(
proxy_passwd
.
encode
())
.
decode
(
'ascii'
)
else
:
else
:
proxy_auth
=
None
proxy_auth
=
None
if
user_passwd
:
if
user_passwd
:
import
base64
user_passwd
=
unquote
(
user_passwd
)
auth
=
base64
.
b64encode
(
user_passwd
.
encode
())
.
decode
(
'ascii'
)
auth
=
base64
.
b64encode
(
user_passwd
.
encode
())
.
decode
(
'ascii'
)
else
:
else
:
auth
=
None
auth
=
None
...
@@ -1871,7 +1871,6 @@ class URLopener:
...
@@ -1871,7 +1871,6 @@ class URLopener:
time
.
gmtime
(
time
.
time
())))
time
.
gmtime
(
time
.
time
())))
msg
.
append
(
'Content-type:
%
s'
%
type
)
msg
.
append
(
'Content-type:
%
s'
%
type
)
if
encoding
==
'base64'
:
if
encoding
==
'base64'
:
import
base64
# XXX is this encoding/decoding ok?
# XXX is this encoding/decoding ok?
data
=
base64
.
decodebytes
(
data
.
encode
(
'ascii'
))
.
decode
(
'latin1'
)
data
=
base64
.
decodebytes
(
data
.
encode
(
'ascii'
))
.
decode
(
'latin1'
)
else
:
else
:
...
...
Misc/NEWS
Dosyayı görüntüle @
c5c5a145
...
@@ -97,6 +97,9 @@ Core and Builtins
...
@@ -97,6 +97,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #13642: Unquote before b64encoding user:password during Basic
Authentication. Patch contributed by Joonas Kuorilehto.
- Issue #13726: Fix the ambiguous -S flag in regrtest. It is -o/--slow for slow
- Issue #13726: Fix the ambiguous -S flag in regrtest. It is -o/--slow for slow
tests.
tests.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment