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
6a2a6c2e
Commit
6a2a6c2e
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 with HTTP Basic Authentation in urllib2.
parent
8349bc2b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+16
-0
Lib/urllib2.py
Lib/urllib2.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib2.py
View file @
6a2a6c2e
...
...
@@ -1112,6 +1112,22 @@ 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
=
urllib2
.
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
=
urllib2
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com:3128"
))
...
...
Lib/urllib2.py
View file @
6a2a6c2e
...
...
@@ -828,7 +828,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 @
6a2a6c2e
...
...
@@ -60,6 +60,9 @@ Core and Builtins
Library
-------
-
Issue
#
12541
:
Be
lenient
with
quotes
around
Realm
field
with
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