464869 PathResource.addPath allows absolute resolution.

Added test harness to demonstrate
Applied suggested fix - which fixes the test.

Need to analyse why this every worked, why it was not detected and what are the ramifications in 9.2.x and 9.3.x releases
This commit is contained in:
Greg Wilkins 2015-04-20 11:34:36 +10:00
parent 6fa863d6be
commit aa3c881eec
2 changed files with 18 additions and 1 deletions

View File

@ -107,7 +107,7 @@ public class PathResource extends Resource
@Override
public Resource addPath(String apath) throws IOException, MalformedURLException
{
return new PathResource(this.path.resolve(apath));
return new PathResource(this.path.getFileSystem().getPath(path.toString(), apath));
}
@Override

View File

@ -110,6 +110,23 @@ public abstract class AbstractFSResourceTest
}
}
@Test
public void testAddPath() throws Exception
{
File dir = testdir.getDir();
File subdir = new File(dir,"sub");
FS.ensureDirExists(subdir);
try (Resource base = newResource(testdir.getDir()))
{
Resource sub = base.addPath("sub");
assertThat("sub/.isDirectory",sub.isDirectory(),is(true));
Resource tmp = sub.addPath("/tmp");
assertThat("No root",tmp.exists(),is(false));
}
}
@Test
public void testIsDirectory() throws Exception
{