diff options
author | Veli-Matti Lintu <veli-matti.lintu@nosto.com> | 2017-08-18 11:48:09 +0300 |
---|---|---|
committer | Joffrey F <f.joffrey@gmail.com> | 2017-08-21 12:01:50 -0700 |
commit | 3df0653493d5f2ff5e17de8211a32aed8f4c1965 (patch) | |
tree | 4b489686e1fee257f3c00973783534eff911347a | |
parent | 477f236c71b4892e876337c79f1b88be1ad9f570 (diff) | |
download | docker-py-3df0653493d5f2ff5e17de8211a32aed8f4c1965.tar.gz |
Commit d798afca made changes for the handling of '**' patterns in
.dockerignore. This causes an IndexError with patterns ending
with '**', e.g. 'subdir/**'. This adds a missing boundary check
before checking for trailing '/'.
Signed-off-by: Veli-Matti Lintu <veli-matti.lintu@nosto.com>
-rw-r--r-- | docker/utils/fnmatch.py | 2 | ||||
-rw-r--r-- | tests/unit/utils_test.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/docker/utils/fnmatch.py b/docker/utils/fnmatch.py index e51bd81..42461dd 100644 --- a/docker/utils/fnmatch.py +++ b/docker/utils/fnmatch.py @@ -75,7 +75,7 @@ def translate(pat): # is some flavor of "**" i = i + 1 # Treat **/ as ** so eat the "/" - if pat[i] == '/': + if i < n and pat[i] == '/': i = i + 1 if i >= n: # is "**EOF" - to align with .gitignore just accept all diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 4a391fa..2fa1d05 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -874,6 +874,23 @@ class ExcludePathsTest(unittest.TestCase): ) ) + def test_trailing_double_wildcard(self): + assert self.exclude(['subdir/**']) == convert_paths( + self.all_paths - set( + ['subdir/file.txt', + 'subdir/target/file.txt', + 'subdir/target/subdir/file.txt', + 'subdir/subdir2/file.txt', + 'subdir/subdir2/target/file.txt', + 'subdir/subdir2/target/subdir/file.txt', + 'subdir/target', + 'subdir/target/subdir', + 'subdir/subdir2', + 'subdir/subdir2/target', + 'subdir/subdir2/target/subdir'] + ) + ) + class TarTest(unittest.TestCase): def test_tar_with_excludes(self): |