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
0d12ead0
Commit
0d12ead0
authored
Feb 14, 1996
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to normalize urls referring to local files (code copied from posixpath)
parent
e708f400
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
Lib/urllib.py
Lib/urllib.py
+15
-3
No files found.
Lib/urllib.py
View file @
0d12ead0
...
...
@@ -33,8 +33,20 @@ if os.name == 'mac':
if
tp
and
tp
<>
'file'
:
raise
RuntimeError
,
'Cannot convert non-local URL to pathname'
components
=
string
.
split
(
pathname
,
'/'
)
if
'..'
in
components
or
'.'
in
components
or
''
in
components
[
1
:
-
1
]:
raise
RuntimeError
,
'Cannot convert URL containing ., .. or // to pathname'
i
=
0
while
i
<
len
(
components
):
if
components
[
i
]
==
'.'
:
del
components
[
i
]
elif
components
[
i
]
==
'..'
and
i
>
0
and
\
components
[
i
-
1
]
not
in
(
''
,
'..'
):
del
components
[
i
-
1
:
i
+
1
]
i
=
i
-
1
elif
components
[
i
]
==
''
and
i
>
0
and
components
[
i
-
1
]
<>
''
:
del
components
[
i
]
else
:
i
=
i
+
1
if
not
components
or
'..'
in
components
or
'.'
in
components
or
''
in
components
[
1
:
-
1
]:
raise
RuntimeError
,
'Cannot normalize URL containing ., .. or // to pathname'
if
not
components
[
0
]:
# Absolute unix path, don't start with colon
return
string
.
join
(
components
[
1
:],
':'
)
...
...
@@ -475,7 +487,7 @@ class ftpwrapper:
if
file
:
cmd
=
'LIST '
+
file
else
:
cmd
=
'LIST'
conn
=
self
.
ftp
.
transfercmd
(
cmd
)
return
addclosehook
(
conn
.
makefile
(
'r'
),
self
.
ftp
.
voidresp
)
return
addclosehook
(
conn
.
makefile
(
'r
b
'
),
self
.
ftp
.
voidresp
)
# Base class for addinfo and addclosehook
class
addbase
:
...
...
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