提交 3f790193 编写于 作者: C chegar

6687919: REGRESSION : Classloader can handle any resource which is not included in classpath

Reviewed-by: jccollet, alanb
上级 777fbe94
...@@ -961,6 +961,7 @@ public class URLClassPath { ...@@ -961,6 +961,7 @@ public class URLClassPath {
* from a file URL that refers to a directory. * from a file URL that refers to a directory.
*/ */
private static class FileLoader extends Loader { private static class FileLoader extends Loader {
/* Canonicalized File */
private File dir; private File dir;
FileLoader(URL url) throws IOException { FileLoader(URL url) throws IOException {
...@@ -970,7 +971,7 @@ public class URLClassPath { ...@@ -970,7 +971,7 @@ public class URLClassPath {
} }
String path = url.getFile().replace('/', File.separatorChar); String path = url.getFile().replace('/', File.separatorChar);
path = ParseUtil.decode(path); path = ParseUtil.decode(path);
dir = new File(path); dir = (new File(path)).getCanonicalFile();
} }
/* /*
...@@ -997,8 +998,19 @@ public class URLClassPath { ...@@ -997,8 +998,19 @@ public class URLClassPath {
if (check) if (check)
URLClassPath.check(url); URLClassPath.check(url);
final File file =
new File(dir, name.replace('/', File.separatorChar)); final File file;
if (name.indexOf("..") != -1) {
file = (new File(dir, name.replace('/', File.separatorChar)))
.getCanonicalFile();
if ( !((file.getPath()).startsWith(dir.getPath())) ) {
/* outside of base dir */
return null;
}
} else {
file = new File(dir, name.replace('/', File.separatorChar));
}
if (file.exists()) { if (file.exists()) {
return new Resource() { return new Resource() {
public String getName() { return name; }; public String getName() { return name; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册