diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-05-15 22:21:01 +0200 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-05-15 22:21:01 +0200 |
commit | 12ea86adcea986c5572c597b72253d839f4d303a (patch) | |
tree | db1cf22fe78ad8f96da1f2d47a1928854b3564dd /Lib/urllib/request.py | |
parent | b28df76ee2cdd0bb2a941bc179f347c26e4254f5 (diff) | |
parent | 9b704ec9e1049788157a7f042ef765a4bb058b68 (diff) | |
download | cpython-git-12ea86adcea986c5572c597b72253d839f4d303a.tar.gz |
merge heads
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r-- | Lib/urllib/request.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a5f0866cb6..96bb8d7068 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -895,7 +895,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" @@ -934,6 +934,9 @@ class AbstractBasicAuthHandler: mo = AbstractBasicAuthHandler.rx.search(authreq) if mo: scheme, quote, realm = mo.groups() + if quote not in ['"',"'"]: + warnings.warn("Basic Auth Realm was unquoted", + UserWarning, 2) if scheme.lower() == 'basic': response = self.retry_http_basic_auth(host, req, realm) if response and response.code != 401: |