mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support non-canonical resource paths in UrlClassLoader
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.util.lang;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.win32.IdeaWin32;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Function;
|
||||
@@ -281,8 +282,7 @@ public class UrlClassLoader extends ClassLoader {
|
||||
|
||||
@Nullable
|
||||
private Resource _getResource(final String name) {
|
||||
String n = name;
|
||||
n = StringUtil.trimStart(n, "/");
|
||||
String n = StringUtil.trimStart(FileUtil.toCanonicalUriPath(name), "/");
|
||||
return getClassPath().getResource(n, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,17 @@ public class UrlClassLoaderTest {
|
||||
assertNotNull(UrlClassLoader.build().allowBootstrapResources().get().getResourceAsStream(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonCanonicalPaths() throws IOException {
|
||||
File root = FileUtil.createTempDirectory("testNonCanonicalPaths", "");
|
||||
File subDir = createTestDir(root, "dir");
|
||||
createTestFile(subDir, "a.txt");
|
||||
|
||||
UrlClassLoader loader = UrlClassLoader.build().urls(root.toURI().toURL()).get();
|
||||
assertNotNull(loader.getResourceAsStream("/dir/a.txt"));
|
||||
assertNotNull(loader.getResourceAsStream("/dir/a.txt/../a.txt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConcurrentResourceLoading() throws Exception {
|
||||
List<String> resourceNames = ContainerUtil.newArrayList();
|
||||
|
||||
Reference in New Issue
Block a user