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:
parent
6fa863d6be
commit
aa3c881eec
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue