Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dockerignore-ascii-digit-class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@e2b/dockerfile-utils-python": patch
---

Keep bracket digit classes in Dockerignore patterns ASCII-only, matching Moby and the JavaScript utility. Non-ASCII decimal digits are no longer excluded by a pattern such as `[\d]`.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _compile(pattern: str, backslash_is_escape: bool) -> Callable[[str], bool]:
return lambda path: path.endswith(suffix) or (
suffix.startswith("/") and path == suffix[1:]
)
compiled = re.compile(regex + r"\Z")
compiled = re.compile(regex + r"\Z", flags=re.ASCII)
return lambda path: compiled.match(path) is not None


Expand Down
8 changes: 8 additions & 0 deletions packages/dockerfile-utils-python/tests/test_dockerignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ def test_rejects_invalid_patterns_with_value_error():
PatternMatcher(["[abc"])
with pytest.raises(ValueError, match=r"Invalid ignore pattern '\[\\q\]'"):
PatternMatcher(["[\\q]"])


@pytest.mark.parametrize(
("path", "excluded"),
[("5", True), ("\u0661", False), ("d", False)],
)
def test_digit_class_only_matches_ascii_digits(path, excluded):
assert PatternMatcher([r"[\d]"]).matches(path) is excluded