Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
91d769e8
Commit
91d769e8
authored
Jan 27, 2019
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow Windows absolute paths unconditionally with no deprecation period.
parent
36a6a8bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
pkg_resources/__init__.py
pkg_resources/__init__.py
+24
-3
No files found.
pkg_resources/__init__.py
View file @
91d769e8
...
@@ -39,6 +39,8 @@ import tempfile
...
@@ -39,6 +39,8 @@ import tempfile
import
textwrap
import
textwrap
import
itertools
import
itertools
import
inspect
import
inspect
import
ntpath
import
posixpath
from
pkgutil
import
get_importer
from
pkgutil
import
get_importer
try
:
try
:
...
@@ -1497,15 +1499,34 @@ class NullProvider:
...
@@ -1497,15 +1499,34 @@ class NullProvider:
>>> vrp('
foo
/
f
..
/
bar
.
txt
')
>>> vrp('
foo
/
f
..
/
bar
.
txt
')
>>> bool(warned)
>>> bool(warned)
False
False
Windows path separators are straight-up disallowed.
>>> vrp(r'
\\
foo
/
bar
.
txt
')
Traceback (most recent call last):
...
ValueError: Use of .. or absolute path in a resource path
\
is not allowed.
>>> vrp(r'
C
:
\\
foo
/
bar
.
txt
')
Traceback (most recent call last):
...
ValueError: Use of .. or absolute path in a resource path
\
is not allowed.
"""
"""
invalid = (
invalid = (
'
..
' in path.split('
/
') or
os.path.pardir in path.split(posixpath.sep) or
path.startswith('
/
')
posixpath.isabs(path) or
ntpath.isabs(path)
)
)
if not invalid:
if not invalid:
return
return
msg = "Use of .. or leading '
/
' in a resource path is not allowed."
msg = "Use of .. or absolute path in a resource path is not allowed."
# Aggressively disallow Windows absolute paths
if ntpath.isabs(path) and not posixpath.isabs(path):
raise ValueError(msg)
# for compatibility, warn; in future
# for compatibility, warn; in future
# raise ValueError(msg)
# raise ValueError(msg)
warnings.warn(
warnings.warn(
...
...
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