]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35907: Complete test_urllib.test_local_file_open() (GH-13506)
authorVictor Stinner <vstinner@redhat.com>
Wed, 22 May 2019 21:28:03 +0000 (23:28 +0200)
committerGitHub <noreply@github.com>
Wed, 22 May 2019 21:28:03 +0000 (23:28 +0200)
Test also URLopener().open(), URLopener().retrieve(), and
DummyURLopener().retrieve().

Lib/test/test_urllib.py
Misc/NEWS.d/next/Library/2019-02-13-17-21-10.bpo-35907.ckk2zg.rst

index ae1f6c0b29f0bed37b1338ba502e652681cc4313..22b0874a92812c5a64f0721d4e8835645d20f96c 100644 (file)
@@ -1049,12 +1049,16 @@ class URLopener_Tests(unittest.TestCase):
             "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
 
     def test_local_file_open(self):
+        # bpo-35907, CVE-2019-9948: urllib must reject local_file:// scheme
         class DummyURLopener(urllib.URLopener):
             def open_local_file(self, url):
                 return url
         for url in ('local_file://example', 'local-file://example'):
-            self.assertRaises(IOError, DummyURLopener().open, url)
             self.assertRaises(IOError, urllib.urlopen, url)
+            self.assertRaises(IOError, urllib.URLopener().open, url)
+            self.assertRaises(IOError, urllib.URLopener().retrieve, url)
+            self.assertRaises(IOError, DummyURLopener().open, url)
+            self.assertRaises(IOError, DummyURLopener().retrieve, url)
 
 # Just commented them out.
 # Can't really tell why keep failing in windows and sparc.
index bb187d8d65a55a434dd9047bc401aefc49d6b616..6a448ce6261c279332c9adc666f1a49070333f59 100644 (file)
@@ -1 +1,3 @@
-CVE-2019-9948: Avoid file reading as disallowing the unnecessary URL scheme in urllib.urlopen
+CVE-2019-9948: Avoid file reading as disallowing the unnecessary URL scheme in
+:func:`urllib.urlopen`, :meth:`urllib.URLopener.open` and
+:meth:`urllib.URLopener.retrieve`.