Merged revisions 78268 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78268 | senthil.kumaran | 2010-02-21 03:35:34 +0530 (Sun, 21 Feb 2010) | 3 lines

  Fix for Issue7751: urllib.urlopen("///C|/foo/bar/spam.foo")
........
This commit is contained in:
Senthil Kumaran 2010-02-20 22:13:01 +00:00
parent 502f8eb50b
commit a241d0a8a2
2 changed files with 6 additions and 2 deletions

View File

@ -94,7 +94,6 @@ class urlopen_FileTests(unittest.TestCase):
for line in self.returned_obj.__iter__(): for line in self.returned_obj.__iter__():
self.assertEqual(line, self.text) self.assertEqual(line, self.text)
class ProxyTests(unittest.TestCase): class ProxyTests(unittest.TestCase):
def setUp(self): def setUp(self):
@ -592,6 +591,11 @@ class URLopener_Tests(unittest.TestCase):
self.assertEqual(DummyURLopener().open( self.assertEqual(DummyURLopener().open(
'spam://example/ /'),'//example/%20/') 'spam://example/ /'),'//example/%20/')
# test the safe characters are not quoted by urlopen
self.assertEqual(DummyURLopener().open(
"spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
# Just commented them out. # Just commented them out.
# Can't really tell why keep failing in windows and sparc. # Can't really tell why keep failing in windows and sparc.

View File

@ -177,7 +177,7 @@ class URLopener:
fullurl = unwrap(toBytes(fullurl)) fullurl = unwrap(toBytes(fullurl))
# percent encode url. fixing lame server errors like space within url # percent encode url. fixing lame server errors like space within url
# parts # parts
fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]") fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
if self.tempcache and fullurl in self.tempcache: if self.tempcache and fullurl in self.tempcache:
filename, headers = self.tempcache[fullurl] filename, headers = self.tempcache[fullurl]
fp = open(filename, 'rb') fp = open(filename, 'rb')