mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
Fix for the Issue918368 - urllib doesn't correct server returned urls
This commit is contained in:
parent
a7e734fcee
commit
7c2867fcb1
2 changed files with 16 additions and 0 deletions
|
@ -176,6 +176,9 @@ class URLopener:
|
|||
def open(self, fullurl, data=None):
|
||||
"""Use URLopener().open(file) instead of open(file, 'r')."""
|
||||
fullurl = unwrap(toBytes(fullurl))
|
||||
# percent encode url, fixing lame server errors for e.g, like space
|
||||
# within url paths.
|
||||
fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]")
|
||||
if self.tempcache and fullurl in self.tempcache:
|
||||
filename, headers = self.tempcache[fullurl]
|
||||
fp = open(filename, 'rb')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue