cpython: f6008e936fbc (original) (raw)
Mercurial > cpython
changeset 74546:f6008e936fbc 2.7
Fix Issue6631 - Disallow relative files paths in urllib*.open()
Senthil Kumaran senthil@uthcode.com | |
---|---|
date | Sat, 21 Jan 2012 11:43:02 +0800 |
parents | 5ecf650ede7c |
children | 4366c0df2c73 |
files | Lib/test/test_urllib.py Lib/test/test_urllib2net.py Lib/urllib.py |
diffstat | 3 files changed, 7 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_urllib.py 3 Lib/test/test_urllib2net.py 2 Lib/urllib.py 2 |
line wrap: on
line diff
--- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -134,6 +134,9 @@ class urlopen_FileTests(unittest.TestCas for line in self.returned_obj.iter(): self.assertEqual(line, self.text)
- def test_relativelocalfile(self):
self.assertRaises(ValueError,urllib.urlopen,'./' + self.pathname)[](#l1.8)
+ class ProxyTests(unittest.TestCase): def setUp(self):
--- a/Lib/test/test_urllib2net.py +++ b/Lib/test/test_urllib2net.py @@ -126,6 +126,8 @@ class OtherNetworkTests(unittest.TestCas finally: os.remove(TESTFN)
self.assertRaises(ValueError, urllib2.urlopen,'./relative_path/to/file')[](#l2.7)
+ # XXX Following test depends on machine configurations that are internal # to CNRI. Need to set up a public server with the right authentication # configuration for test purposes.
--- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -484,6 +484,8 @@ class URLopener: urlfile = file if file[:1] == '/': urlfile = 'file://' + file
elif file[:2] == './':[](#l3.7)
raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)[](#l3.8) return addinfourl(open(localname, 'rb'),[](#l3.9) headers, urlfile)[](#l3.10) host, port = splitport(host)[](#l3.11)