Fix matchesWildcard to safely handle regex metacharacters in feature filter#7151
Fix matchesWildcard to safely handle regex metacharacters in feature filter#7151peterkir merged 4 commits intoecl-fea-supportfrom
matchesWildcard to safely handle regex metacharacters in feature filter#7151Conversation
…rn.quote Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
|
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
matchesWildcard to safely handle regex metacharacters in feature filter
| return str.toLowerCase() | ||
| .matches(regex.toLowerCase()); | ||
| // Split on '*', quote each segment, then join with '.*' | ||
| String[] segments = wildcardPattern.split("\\*", -1); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Thx for the hint. @copilot change implementation of wildcard to use the aQute.libg.glob.Glob class
There was a problem hiding this comment.
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.
Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
Co-authored-by: peterkir <250545+peterkir@users.noreply.github.com>
|
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
matchesWildcardinRepositoryTreeContentProvideronly escaped.before callingString.matches(), leaving metacharacters like[,(,\,?,+unescaped and causingPatternSyntaxExceptionthat would break the repository tree UI filter.Changes
aQute.libg.glob.Globfor wildcard matching: Replaces the custom regex-building logic with the existingGlobclass already used throughoutbndtools.corefor wildcard filtering, ensuring consistent and safe handling of all regex metacharacters.Globinstance: TheGlobinstance is pre-compiled insetFilter()and stored aswildcardGlob, so regex compilation happens only once when the user changes the filter — not on every feature-ID comparison.Pattern.CASE_INSENSITIVEflag when constructing theGlob, replacing the previous ad-hoc.toLowerCase()calls.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.