Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
383c32dd
Commit
383c32dd
authored
Oct 14, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue10063 - file:// scheme will stop accessing remote hosts via ftp protocol
parent
6d7be5f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
7 deletions
+17
-7
Doc/library/urllib.request.rst
Doc/library/urllib.request.rst
+6
-2
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+2
-2
Lib/urllib/request.py
Lib/urllib/request.py
+3
-3
Misc/NEWS
Misc/NEWS
+6
-0
No files found.
Doc/library/urllib.request.rst
View file @
383c32dd
...
...
@@ -1004,8 +1004,12 @@ FileHandler Objects
.. method:: FileHandler.file_open(req)
Open the file locally, if there is no host name, or the host name is
``'localhost'``. Change the protocol to ``ftp`` otherwise, and retry opening it
using :attr:`parent`.
``'localhost'``.
This method is applicable only for local hostnames. When a remote hostname
is given, an :exc:`URLError` is raised.
.. versionchanged:: 3.2
.. _ftp-handler-objects:
...
...
Lib/test/test_urllib2.py
View file @
383c32dd
...
...
@@ -731,11 +731,11 @@ class HandlerTests(unittest.TestCase):
# file:///blah.txt (a file)
# file://ftp.example.com/blah.txt (an ftp URL)
for
url
,
ftp
in
[
(
"file://ftp.example.com//foo.txt"
,
Tru
e
),
(
"file://ftp.example.com//foo.txt"
,
Fals
e
),
(
"file://ftp.example.com///foo.txt"
,
False
),
# XXXX bug: fails with OSError, should be URLError
(
"file://ftp.example.com/foo.txt"
,
False
),
(
"file://somehost//foo/something.txt"
,
Tru
e
),
(
"file://somehost//foo/something.txt"
,
Fals
e
),
(
"file://localhost//foo/something.txt"
,
False
),
]:
req
=
Request
(
url
)
...
...
Lib/urllib/request.py
View file @
383c32dd
...
...
@@ -1228,8 +1228,8 @@ class FileHandler(BaseHandler):
url
=
req
.
selector
if
url
[:
2
]
==
'//'
and
url
[
2
:
3
]
!=
'/'
and
(
req
.
host
and
req
.
host
!=
'localhost'
):
req
.
type
=
'ftp'
return
self
.
parent
.
open
(
req
)
if
not
req
.
host
is
self
.
get_names
():
raise
URLError
(
"file:// scheme is supported only on localhost"
)
else
:
return
self
.
open_local_file
(
req
)
...
...
@@ -1712,7 +1712,7 @@ class URLopener:
if
not
isinstance
(
url
,
str
):
raise
URLError
(
'file error'
,
'proxy support for file protocol currently not implemented'
)
if
url
[:
2
]
==
'//'
and
url
[
2
:
3
]
!=
'/'
and
url
[
2
:
12
].
lower
()
!=
'localhost/'
:
r
eturn
self
.
open_ftp
(
url
)
r
aise
ValueError
(
"file:// scheme is supported only on localhost"
)
else
:
return
self
.
open_local_file
(
url
)
...
...
Misc/NEWS
View file @
383c32dd
...
...
@@ -18,6 +18,12 @@ Core and Builtins
Library
-------
- Issue #Issue10063: file:// scheme will stop accessing remote hosts via ftp
protocol. file:// urls had fallback to access remote hosts via ftp. This was
not correct, change is made to raise a URLError when a remote host is tried
to access via file:// scheme.
- Issue #1710703: Write structures for an empty ZIP archive when a ZipFile is
created in modes 'a' or 'w' and then closed without adding any files. Raise
BadZipfile (rather than IOError) when opening small non-ZIP files.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment