Blame SOURCES/00325-CVE-2019-9948.patch

b9ffd2
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
b9ffd2
index 649a5b8..0061a52 100644
b9ffd2
--- a/Lib/test/test_urllib.py
b9ffd2
+++ b/Lib/test/test_urllib.py
b9ffd2
@@ -16,6 +16,7 @@ except ImportError:
b9ffd2
     ssl = None
b9ffd2
 import sys
b9ffd2
 import tempfile
b9ffd2
+import warnings
b9ffd2
 from nturl2path import url2pathname, pathname2url
b9ffd2
 
b9ffd2
 from base64 import b64encode
b9ffd2
@@ -1463,6 +1464,23 @@ class URLopener_Tests(unittest.TestCase):
b9ffd2
                 "spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
b9ffd2
                 "//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
b9ffd2
 
b9ffd2
+    def test_local_file_open(self):
b9ffd2
+        # bpo-35907, CVE-2019-9948: urllib must reject local_file:// scheme
b9ffd2
+        class DummyURLopener(urllib.request.URLopener):
b9ffd2
+            def open_local_file(self, url):
b9ffd2
+                return url
b9ffd2
+
b9ffd2
+        with warnings.catch_warnings(record=True):
b9ffd2
+            warnings.simplefilter("ignore", DeprecationWarning)
b9ffd2
+
b9ffd2
+            for url in ('local_file://example', 'local-file://example'):
b9ffd2
+                self.assertRaises(OSError, urllib.request.urlopen, url)
b9ffd2
+                self.assertRaises(OSError, urllib.request.URLopener().open, url)
b9ffd2
+                self.assertRaises(OSError, urllib.request.URLopener().retrieve, url)
b9ffd2
+                self.assertRaises(OSError, DummyURLopener().open, url)
b9ffd2
+                self.assertRaises(OSError, DummyURLopener().retrieve, url)
b9ffd2
+
b9ffd2
+
b9ffd2
 # Just commented them out.
b9ffd2
 # Can't really tell why keep failing in windows and sparc.
b9ffd2
 # Everywhere else they work ok, but on those machines, sometimes
b9ffd2
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
b9ffd2
index d28f2f8..c9945d9 100644
b9ffd2
--- a/Lib/urllib/request.py
b9ffd2
+++ b/Lib/urllib/request.py
b9ffd2
@@ -1747,7 +1747,7 @@ class URLopener:
b9ffd2
         name = 'open_' + urltype
b9ffd2
         self.type = urltype
b9ffd2
         name = name.replace('-', '_')
b9ffd2
-        if not hasattr(self, name):
b9ffd2
+        if not hasattr(self, name) or name == 'open_local_file':
b9ffd2
             if proxy:
b9ffd2
                 return self.open_unknown_proxy(proxy, fullurl, data)
b9ffd2
             else: