Skip to content

Commit a14b672

Browse files
committed
Escape stars in matching text when fetching hosted only content
1 parent ed06e3a commit a14b672

File tree

1 file changed

+9
-5
lines changed
  • substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/resources/CompressedGlobTrie

1 file changed

+9
-5
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/resources/CompressedGlobTrie/CompressedGlobTrie.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ public static <C> void finalize(GlobTrieNode<C> root) {
352352
*/
353353
@Platforms(Platform.HOSTED_ONLY.class)
354354
public static <C> List<C> getHostedOnlyContentIfMatched(GlobTrieNode<C> root, String text) {
355-
List<GlobTrieNode<C>> matchedNodes = new ArrayList<>();
356-
getAllPatterns(root, getPatternParts(text), 0, matchedNodes);
355+
List<GlobTrieNode<C>> matchedNodes = getAllMatchedNodes(root, text);
357356
if (matchedNodes.isEmpty()) {
358357
/* text cannot be matched */
359358
return null;
@@ -368,11 +367,16 @@ public static <C> List<C> getHostedOnlyContentIfMatched(GlobTrieNode<C> root, St
368367
* Returns whether given text can be matched with any glob pattern in the Trie or not.
369368
*/
370369
public static <C> boolean match(GlobTrieNode<C> root, String text) {
370+
return !getAllMatchedNodes(root, text).isEmpty();
371+
}
372+
373+
private static <C> List<GlobTrieNode<C>> getAllMatchedNodes(GlobTrieNode<C> root, String text) {
371374
/* in this case text is a plain text without special meanings, so stars must be escaped */
372375
String escapedText = escapeAllStars(text);
373-
List<GlobTrieNode<C>> tmp = new ArrayList<>();
374-
getAllPatterns(root, getPatternParts(escapedText), 0, tmp);
375-
return !tmp.isEmpty();
376+
List<GlobTrieNode<C>> matchedNodes = new ArrayList<>();
377+
getAllPatterns(root, getPatternParts(escapedText), 0, matchedNodes);
378+
379+
return matchedNodes;
376380
}
377381

378382
private static String escapeAllStars(String text) {

0 commit comments

Comments
 (0)