Skip to content

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Sep 15, 2025

This PR simplifies support for the ** wildcard and clarifies brace handling.

What changes

  • Convert **/ to {**/,} after escaping special characters (including braces)
  • Escape user-provided { and } in Maven-style patterns so braces are treated literally
  • Keep brace alternation available when the user explicitly opts into glob: syntax
  • Add focused tests for literal braces and explicit glob: alternation

Why

  • Provides clear, POSIX-like behavior for ** (“zero or more directories”) without custom logic
  • Aligns implementation with the documented rule that [ ] and { } are escaped in Maven-style patterns
  • Ensures only the injected braces participate in expansion; user braces remain literals unless glob: is used

Behavior notes

  • ** continues to mean “0+ directories”; **/ is normalized to {**/,} so both the current directory and subdirectories match
  • Users who relied on unescaped braces acting as alternation in Maven-style patterns may see a behavior change; this corrects behavior to match the documentation
  • With glob: prefix, brace alternation remains supported per NIO glob rules

Tests

  • testLiteralBracesAreEscapedInMavenSyntax: verifies that files with literal braces match with Maven-style patterns
  • testBraceAlternationOnlyWithExplicitGlob: verifies alternation works only with glob:

Fixes #11110

- Convert "**/" to "{**/,}" after escaping special chars (including braces)
- Treat user braces literally in Maven-style patterns; alternation remains with explicit glob:
- Add tests for literal braces and explicit glob alternation

Fixes apache#11110
@gnodet gnodet changed the title Fix 11110 Simplify “**” handling using brace expansion (fixes #11110) Sep 16, 2025
@gnodet gnodet requested a review from desruisseaux September 16, 2025 08:05
@gnodet gnodet marked this pull request as ready for review September 16, 2025 08:06
@gnodet gnodet added the enhancement New feature or request label Sep 17, 2025
@gnodet gnodet merged commit f01db87 into apache:master Sep 17, 2025
19 checks passed
@github-actions github-actions bot added this to the 4.1.0 milestone Sep 17, 2025
desruisseaux pushed a commit to Geomatys/maven that referenced this pull request Dec 14, 2025
This simplification appears to also fix a bug.
@desruisseaux
Copy link
Contributor

Needs to be backported to the maven-4.0.x branch as this pull request also fixes the testWildcardMatchesAlsoZeroDirectory test case added by #11551. Waiting to see if #11551 is accepted in order to opportunistically include the two pull requests in a single backport.

desruisseaux pushed a commit to Geomatys/maven that referenced this pull request Dec 15, 2025
- Convert "**/" to "{**/,}" after escaping special chars (including braces)
- Treat user braces literally in Maven-style patterns; alternation remains with explicit glob:
- Add tests for literal braces and explicit glob alternation

Fixes apache#11110
desruisseaux pushed a commit that referenced this pull request Dec 16, 2025
- Convert "**/" to "{**/,}" after escaping special chars (including braces)
- Treat user braces literally in Maven-style patterns; alternation remains with explicit glob:
- Add tests for literal braces and explicit glob alternation

Fixes #11110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-4.0.x enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve PathSelector to use brace expansion for POSIX ** semantics instead of combinatorial approach

2 participants