Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
34f3fcc2
Commit
34f3fcc2
authored
May 15, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12541: Be lenient with quotes around Realm field of HTTP Basic Authentation in urllib2.
G: changed Misc/NEWS
parent
539f239e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+15
-0
Lib/urllib/request.py
Lib/urllib/request.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib2.py
View file @
34f3fcc2
...
...
@@ -1218,6 +1218,21 @@ class HandlerTests(unittest.TestCase):
def
test_basic_auth_with_single_quoted_realm
(
self
):
self
.
test_basic_auth
(
quote_char
=
"'"
)
def
test_basic_auth_with_unquoted_realm
(
self
):
opener
=
OpenerDirector
()
password_manager
=
MockPasswordManager
()
auth_handler
=
urllib
.
request
.
HTTPBasicAuthHandler
(
password_manager
)
realm
=
"ACME Widget Store"
http_handler
=
MockHTTPHandler
(
401
,
'WWW-Authenticate: Basic realm=%s
\
r
\
n
\
r
\
n
'
%
realm
)
opener
.
add_handler
(
auth_handler
)
opener
.
add_handler
(
http_handler
)
self
.
_test_basic_auth
(
opener
,
auth_handler
,
"Authorization"
,
realm
,
http_handler
,
password_manager
,
"http://acme.example.com/protected"
,
"http://acme.example.com/protected"
,
)
def
test_proxy_basic_auth
(
self
):
opener
=
OpenerDirector
()
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com:3128"
))
...
...
Lib/urllib/request.py
View file @
34f3fcc2
...
...
@@ -794,7 +794,7 @@ class AbstractBasicAuthHandler:
# allow for double- and single-quoted realm values
# (single quotes are a violation of the RFC, but appear in the wild)
rx = re.compile('(?:.*,)*[
\
t
]*([^
\
t
]+)[
\
t
]+'
'realm=(["
\
']
)(.*?
)
\
\
2'
,
re
.
I
)
'realm=(["
\
']
?)([^"
\
'
]*
)
\
\
2'
,
re
.
I
)
# XXX could pre-emptively send auth info already accepted (RFC 2617,
# end of section 2, and section 1.2 immediately after "credentials"
...
...
Misc/NEWS
View file @
34f3fcc2
...
...
@@ -63,6 +63,9 @@ Core and Builtins
Library
-------
- Issue #12541: Be lenient with quotes around Realm field of HTTP Basic
Authentation in urllib2.
- Issue #14662: Prevent shutil failures on OS X when destination does not
support chflag operations. Patch by Hynek Schlawack.
...
...
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