Avoid recompiling pattern in Handler#canonicalize

See gh-21103
This commit is contained in:
dreis2211 2020-04-23 19:41:51 +02:00 committed by Stephane Nicoll
parent 3f96e2165a
commit 848127ae49

View File

@ -49,6 +49,8 @@ public class Handler extends URLStreamHandler {
private static final String SEPARATOR = "!/";
private static final Pattern SEPARATOR_PATTERN = Pattern.compile(SEPARATOR, Pattern.LITERAL);
private static final String CURRENT_DIR = "/./";
private static final Pattern CURRENT_DIR_PATTERN = Pattern.compile(CURRENT_DIR, Pattern.LITERAL);
@ -285,7 +287,7 @@ public class Handler extends URLStreamHandler {
}
private String canonicalize(String path) {
return path.replace(SEPARATOR, "/");
return SEPARATOR_PATTERN.matcher(path).replaceAll("/");
}
public JarFile getRootJarFileFromUrl(URL url) throws IOException {