Commit 2ef16328 authored by Senthil Kumaran's avatar Senthil Kumaran

Stricter verification for file based url scheme and reliance on ftp protocol.

parent 0d62f5bb
...@@ -731,6 +731,8 @@ class HandlerTests(unittest.TestCase): ...@@ -731,6 +731,8 @@ class HandlerTests(unittest.TestCase):
("file://ftp.example.com///foo.txt", False), ("file://ftp.example.com///foo.txt", False),
# XXXX bug: fails with OSError, should be URLError # XXXX bug: fails with OSError, should be URLError
("file://ftp.example.com/foo.txt", False), ("file://ftp.example.com/foo.txt", False),
("file://somehost//foo/something.txt", True),
("file://localhost//foo/something.txt", False),
]: ]:
req = Request(url) req = Request(url)
try: try:
...@@ -741,6 +743,7 @@ class HandlerTests(unittest.TestCase): ...@@ -741,6 +743,7 @@ class HandlerTests(unittest.TestCase):
else: else:
self.assertTrue(o.req is req) self.assertTrue(o.req is req)
self.assertEqual(req.type, "ftp") self.assertEqual(req.type, "ftp")
self.assertEqual(req.type is "ftp", ftp)
def test_http(self): def test_http(self):
......
...@@ -1188,7 +1188,8 @@ class FileHandler(BaseHandler): ...@@ -1188,7 +1188,8 @@ class FileHandler(BaseHandler):
# Use local file or FTP depending on form of URL # Use local file or FTP depending on form of URL
def file_open(self, req): def file_open(self, req):
url = req.selector url = req.selector
if url[:2] == '//' and url[2:3] != '/': if url[:2] == '//' and url[2:3] != '/' and (req.host and
req.host != 'localhost'):
req.type = 'ftp' req.type = 'ftp'
return self.parent.open(req) return self.parent.open(req)
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment