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
69bfb15b
Commit
69bfb15b
authored
Jan 06, 2016
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26012: Don't traverse into symlinks for ** pattern in pathlib.Path.[r]glob().
parent
6c2d33a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
Lib/pathlib.py
Lib/pathlib.py
+1
-1
Lib/test/test_pathlib.py
Lib/test/test_pathlib.py
+18
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pathlib.py
View file @
69bfb15b
...
@@ -496,7 +496,7 @@ class _RecursiveWildcardSelector(_Selector):
...
@@ -496,7 +496,7 @@ class _RecursiveWildcardSelector(_Selector):
yield
parent_path
yield
parent_path
for
name
in
listdir
(
parent_path
):
for
name
in
listdir
(
parent_path
):
path
=
parent_path
.
_make_child_relpath
(
name
)
path
=
parent_path
.
_make_child_relpath
(
name
)
if
is_dir
(
path
):
if
is_dir
(
path
)
and
not
path
.
is_symlink
()
:
for
p
in
self
.
_iterate_directories
(
path
,
is_dir
,
listdir
):
for
p
in
self
.
_iterate_directories
(
path
,
is_dir
,
listdir
):
yield
p
yield
p
...
...
Lib/test/test_pathlib.py
View file @
69bfb15b
...
@@ -1245,7 +1245,7 @@ class _BasePathTest(object):
...
@@ -1245,7 +1245,7 @@ class _BasePathTest(object):
os
.
symlink
(
'non-existing'
,
join
(
'brokenLink'
))
os
.
symlink
(
'non-existing'
,
join
(
'brokenLink'
))
self
.
dirlink
(
'dirB'
,
join
(
'linkB'
))
self
.
dirlink
(
'dirB'
,
join
(
'linkB'
))
self
.
dirlink
(
os
.
path
.
join
(
'..'
,
'dirB'
),
join
(
'dirA'
,
'linkC'
))
self
.
dirlink
(
os
.
path
.
join
(
'..'
,
'dirB'
),
join
(
'dirA'
,
'linkC'
))
# This one goes upwards
but doesn't create
a loop
# This one goes upwards
, creating
a loop
self
.
dirlink
(
os
.
path
.
join
(
'..'
,
'dirB'
),
join
(
'dirB'
,
'linkD'
))
self
.
dirlink
(
os
.
path
.
join
(
'..'
,
'dirB'
),
join
(
'dirB'
,
'linkD'
))
if
os
.
name
==
'nt'
:
if
os
.
name
==
'nt'
:
...
@@ -1380,6 +1380,23 @@ class _BasePathTest(object):
...
@@ -1380,6 +1380,23 @@ class _BasePathTest(object):
_check
(
p
.
rglob
(
"file*"
),
[
"dirC/fileC"
,
"dirC/dirD/fileD"
])
_check
(
p
.
rglob
(
"file*"
),
[
"dirC/fileC"
,
"dirC/dirD/fileD"
])
_check
(
p
.
rglob
(
"*/*"
),
[
"dirC/dirD/fileD"
])
_check
(
p
.
rglob
(
"*/*"
),
[
"dirC/dirD/fileD"
])
@
with_symlinks
def
test_rglob_symlink_loop
(
self
):
# Don't get fooled by symlink loops (Issue #26012)
P
=
self
.
cls
p
=
P
(
BASE
)
given
=
set
(
p
.
rglob
(
'*'
))
expect
=
{
'brokenLink'
,
'dirA'
,
'dirA/linkC'
,
'dirB'
,
'dirB/fileB'
,
'dirB/linkD'
,
'dirC'
,
'dirC/dirD'
,
'dirC/dirD/fileD'
,
'dirC/fileC'
,
'dirE'
,
'fileA'
,
'linkA'
,
'linkB'
,
}
self
.
assertEqual
(
given
,
{
p
/
x
for
x
in
expect
})
def
test_glob_dotdot
(
self
):
def
test_glob_dotdot
(
self
):
# ".." is not special in globs
# ".." is not special in globs
P
=
self
.
cls
P
=
self
.
cls
...
...
Misc/NEWS
View file @
69bfb15b
...
@@ -13,6 +13,9 @@ Core and Builtins
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #26012: Don'
t
traverse
into
symlinks
for
**
pattern
in
pathlib
.
Path
.[
r
]
glob
().
-
Issue
#
24120
:
Ignore
PermissionError
when
traversing
a
tree
with
-
Issue
#
24120
:
Ignore
PermissionError
when
traversing
a
tree
with
pathlib
.
Path
.[
r
]
glob
().
Patch
by
Ulrich
Petri
.
pathlib
.
Path
.[
r
]
glob
().
Patch
by
Ulrich
Petri
.
...
...
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