Fixing Issue6557. urllib.urlopen will quote the space character within urls.

This commit is contained in:
Senthil Kumaran 2009-08-15 17:49:55 +00:00
parent f492c36442
commit b52c6f8c39
2 changed files with 15 additions and 0 deletions

View file

@ -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 like space within url
# parts
fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]")
if self.tempcache and fullurl in self.tempcache:
filename, headers = self.tempcache[fullurl]
fp = open(filename, 'rb')