Skip to content

Commit

Permalink
Correctly handle resource include patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
loicottet committed Nov 13, 2023
1 parent fba956c commit 2368a2f
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,28 @@ public void registerIncludePattern(String module, String pattern) {
assert MissingRegistrationUtils.throwMissingRegistrationErrors();
synchronized (includePatterns) {
updateTimeStamp();
includePatterns.put(new ModuleResourcePair(module, pattern), Boolean.TRUE);
includePatterns.put(new ModuleResourcePair(module, handleEscapedCharacters(pattern)), Boolean.TRUE);
}
}

@Platforms(Platform.HOSTED_ONLY.class)//
private static final String BEGIN_ESCAPED_SEQUENCE = "\\Q";

@Platforms(Platform.HOSTED_ONLY.class)//
private static final String END_ESCAPED_SEQUENCE = "\\E";

/*
* This handles generated include patterns which start and end with \Q and \E. The actual
* resource name is located inbetween those tags.
*/
@Platforms(Platform.HOSTED_ONLY.class)
private static String handleEscapedCharacters(String pattern) {
if (pattern.startsWith(BEGIN_ESCAPED_SEQUENCE) && pattern.endsWith(END_ESCAPED_SEQUENCE)) {
return pattern.substring(BEGIN_ESCAPED_SEQUENCE.length(), pattern.length() - END_ESCAPED_SEQUENCE.length());
}
return pattern;
}

/**
* Avoid pulling native file system by using {@link NativeImageResourcePath} implementation to
* convert <code>resourceName</code> to canonical variant.
Expand Down

0 comments on commit 2368a2f

Please sign in to comment.