Kaydet (Commit) 7f5739dc authored tarafından Joffrey F's avatar Joffrey F Kaydeden (comit) Joffrey F

Leading slash in .dockerignore should be ignored

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 7139e2d8
...@@ -26,6 +26,7 @@ def exclude_paths(root, patterns, dockerfile=None): ...@@ -26,6 +26,7 @@ def exclude_paths(root, patterns, dockerfile=None):
if dockerfile is None: if dockerfile is None:
dockerfile = 'Dockerfile' dockerfile = 'Dockerfile'
patterns = [p.lstrip('/') for p in patterns]
exceptions = [p for p in patterns if p.startswith('!')] exceptions = [p for p in patterns if p.startswith('!')]
include_patterns = [p[1:] for p in exceptions] include_patterns = [p[1:] for p in exceptions]
......
...@@ -768,6 +768,11 @@ class ExcludePathsTest(unittest.TestCase): ...@@ -768,6 +768,11 @@ class ExcludePathsTest(unittest.TestCase):
self.all_paths - set(['foo/a.py']) self.all_paths - set(['foo/a.py'])
) )
def test_single_subdir_single_filename_leading_slash(self):
assert self.exclude(['/foo/a.py']) == convert_paths(
self.all_paths - set(['foo/a.py'])
)
def test_single_subdir_with_path_traversal(self): def test_single_subdir_with_path_traversal(self):
assert self.exclude(['foo/whoops/../a.py']) == convert_paths( assert self.exclude(['foo/whoops/../a.py']) == convert_paths(
self.all_paths - set(['foo/a.py']) self.all_paths - set(['foo/a.py'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment