mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-46756: Fix authorization check in urllib.request (GH-31353)
Fix a bug in urllib.request.HTTPPasswordMgr.find_user_password() and urllib.request.HTTPPasswordMgrWithPriorAuth.is_authenticated() which allowed to bypass authorization. For example, access to URI "example.org/foobar" was allowed if the user was authorized for URI "example.org/foo".
This commit is contained in:
parent
53ecf9e08d
commit
e2e72567a1
3 changed files with 30 additions and 8 deletions
|
@ -889,10 +889,10 @@ class HTTPPasswordMgr:
|
|||
return True
|
||||
if base[0] != test[0]:
|
||||
return False
|
||||
common = posixpath.commonprefix((base[1], test[1]))
|
||||
if len(common) == len(base[1]):
|
||||
return True
|
||||
return False
|
||||
prefix = base[1]
|
||||
if prefix[-1:] != '/':
|
||||
prefix += '/'
|
||||
return test[1].startswith(prefix)
|
||||
|
||||
|
||||
class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue