Skip to content

Commit 942c31d

Browse files
authored
bpo-35907: Complete test_urllib.test_local_file_open() (GH-13506)
Test also URLopener().open(), URLopener().retrieve(), and DummyURLopener().retrieve().
1 parent b15bde8 commit 942c31d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Lib/test/test_urllib.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,12 +1049,16 @@ def open_spam(self, url):
10491049
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
10501050

10511051
def test_local_file_open(self):
1052+
# bpo-35907, CVE-2019-9948: urllib must reject local_file:// scheme
10521053
class DummyURLopener(urllib.URLopener):
10531054
def open_local_file(self, url):
10541055
return url
10551056
for url in ('local_file://example', 'local-file://example'):
1056-
self.assertRaises(IOError, DummyURLopener().open, url)
10571057
self.assertRaises(IOError, urllib.urlopen, url)
1058+
self.assertRaises(IOError, urllib.URLopener().open, url)
1059+
self.assertRaises(IOError, urllib.URLopener().retrieve, url)
1060+
self.assertRaises(IOError, DummyURLopener().open, url)
1061+
self.assertRaises(IOError, DummyURLopener().retrieve, url)
10581062

10591063
# Just commented them out.
10601064
# Can't really tell why keep failing in windows and sparc.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
CVE-2019-9948: Avoid file reading as disallowing the unnecessary URL scheme in urllib.urlopen
1+
CVE-2019-9948: Avoid file reading as disallowing the unnecessary URL scheme in
2+
:func:`urllib.urlopen`, :meth:`urllib.URLopener.open` and
3+
:meth:`urllib.URLopener.retrieve`.

0 commit comments

Comments
 (0)