Skip to content

Fix matchesWildcard to safely handle regex metacharacters in feature filter#7151

Merged
peterkir merged 4 commits intoecl-fea-supportfrom
copilot/sub-pr-7124
Mar 16, 2026
Merged

Fix matchesWildcard to safely handle regex metacharacters in feature filter#7151
peterkir merged 4 commits intoecl-fea-supportfrom
copilot/sub-pr-7124

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 15, 2026

matchesWildcard in RepositoryTreeContentProvider only escaped . before calling String.matches(), leaving metacharacters like [, (, \, ?, + unescaped and causing PatternSyntaxException that would break the repository tree UI filter.

Changes

  • Use aQute.libg.glob.Glob for wildcard matching: Replaces the custom regex-building logic with the existing Glob class already used throughout bndtools.core for wildcard filtering, ensuring consistent and safe handling of all regex metacharacters.
  • Cached Glob instance: The Glob instance is pre-compiled in setFilter() and stored as wildcardGlob, so regex compilation happens only once when the user changes the filter — not on every feature-ID comparison.
  • Case-insensitive matching: Uses Pattern.CASE_INSENSITIVE flag when constructing the Glob, replacing the previous ad-hoc .toLowerCase() calls.
// Before — throws PatternSyntaxException for input like "[eclipse"
String regex = wildcardPattern.replace(".", "\\.").replace("*", ".*");
return str.toLowerCase().matches(regex.toLowerCase());

// After — delegates to Glob with a cached, pre-compiled instance
return new Glob(wildcardPattern, Pattern.CASE_INSENSITIVE).matches(str);

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…rn.quote

Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 15, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bndtools.jfrog.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xms1024m -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xms1024m -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] [WIP] Address feedback on Eclipse Features support PR Fix matchesWildcard to safely handle regex metacharacters in feature filter Mar 15, 2026
Copilot AI requested a review from peterkir March 15, 2026 20:05
return str.toLowerCase()
.matches(regex.toLowerCase());
// Split on '*', quote each segment, then join with '.*'
String[] segments = wildcardPattern.split("\\*", -1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should reuse theaQute.libg.glob.Glob class which is used in lots of other places for wildcard filtering: e.g.

aQute.bnd.osgi.repository.BridgeRepository.list(String)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the hint. @copilot change implementation of wildcard to use the aQute.libg.glob.Glob class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 6972ed79. Replaced the custom pattern logic with aQute.libg.glob.Glob(wildcardPattern, Pattern.CASE_INSENSITIVE).matches(str). The Glob instance is now pre-built in setFilter() and cached as wildcardGlob, so regex compilation only happens once when the filter changes rather than on every feature match.

Copilot AI and others added 2 commits March 16, 2026 05:59
Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bndtools.jfrog.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xms1024m -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xms1024m -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@peterkir peterkir marked this pull request as ready for review March 16, 2026 07:50
@peterkir peterkir merged commit 3b141d4 into ecl-fea-support Mar 16, 2026
20 checks passed
@peterkir peterkir deleted the copilot/sub-pr-7124 branch March 16, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants