diff options
author | Guido van Rossum <guido@python.org> | 2016-01-06 18:31:33 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-01-06 18:31:33 (GMT) |
commit | 69bfb15bd8cb87dd07f1cf6c53f78b399c7ef937 (patch) | |
tree | 38aaacb57b92d4b3405b087d4cf4f5d578b3ba87 /Lib/test | |
parent | 6c2d33a258bb62bc74be4d848968c99c6fbfbba4 (diff) | |
download | cpython-69bfb15bd8cb87dd07f1cf6c53f78b399c7ef937.zip cpython-69bfb15bd8cb87dd07f1cf6c53f78b399c7ef937.tar.gz cpython-69bfb15bd8cb87dd07f1cf6c53f78b399c7ef937.tar.bz2 |
Issue #26012: Don't traverse into symlinks for ** pattern in pathlib.Path.[r]glob().
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_pathlib.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index d272264..f91cda0 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1245,7 +1245,7 @@ class _BasePathTest(object): os.symlink('non-existing', join('brokenLink')) self.dirlink('dirB', join('linkB')) 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')) if os.name == 'nt': @@ -1380,6 +1380,23 @@ class _BasePathTest(object): _check(p.rglob("file*"), ["dirC/fileC", "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): # ".." is not special in globs P = self.cls |