Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.1] Backport: Correctly handle resource include patterns #773

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,28 @@ public void registerIncludePattern(String module, String pattern) {
assert MissingRegistrationUtils.throwMissingRegistrationErrors();
synchronized (includePatterns) {
updateTimeStamp();
includePatterns.add(new ModuleResourcePair(module, pattern));
includePatterns.add(new ModuleResourcePair(module, handleEscapedCharacters(pattern)));
}
}

@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