]> granicus.if.org Git - python/commitdiff
Fix for Issue7751: urllib.urlopen("///C|/foo/bar/spam.foo")
authorSenthil Kumaran <orsenthil@gmail.com>
Sat, 20 Feb 2010 22:05:34 +0000 (22:05 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Sat, 20 Feb 2010 22:05:34 +0000 (22:05 +0000)
Lib/test/test_urllib.py
Lib/urllib.py

index 1d7fd7324e33a71ecf2f41ded6a0f809461bb88f..1cf8e4487b1ca2a69f1843a96dc4507a56c16a14 100644 (file)
@@ -93,7 +93,6 @@ class urlopen_FileTests(unittest.TestCase):
         for line in self.returned_obj.__iter__():
             self.assertEqual(line, self.text)
 
-
 class ProxyTests(unittest.TestCase):
 
     def setUp(self):
@@ -607,6 +606,11 @@ class URLopener_Tests(unittest.TestCase):
         self.assertEqual(DummyURLopener().open(
             '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.
 # Can't really tell why keep failing in windows and sparc.
index d4740e97a79ff7d1e12ed6244989252282c0abbc..58e750a5e20b8c5b0cc3c07adafae41ba6f29d13 100644 (file)
@@ -179,7 +179,7 @@ class URLopener:
         fullurl = unwrap(toBytes(fullurl))
         # percent encode url, fixing lame server errors for e.g, like space
         # within url paths.
-        fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]")
+        fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
         if self.tempcache and fullurl in self.tempcache:
             filename, headers = self.tempcache[fullurl]
             fp = open(filename, 'rb')