git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@432379 13f79535-47bb-0310-9956-ffa450edef68master
@@ -102,6 +102,10 @@ Changes that could break older environments: | |||||
Fixed bugs: | Fixed bugs: | ||||
----------- | ----------- | ||||
* The build could be halted if a file path contained more ".." components than | |||||
the actual depth of the preceding path. Now such paths are left alone (meaning | |||||
they will likely be treated as nonexistent files). Bugzilla Report 40281. | |||||
* Converting a <dirset> to a string was broken. Bugzilla Report 39683. | * Converting a <dirset> to a string was broken. Bugzilla Report 39683. | ||||
* Manifests have improved line length handling, taking care of encoding. | * Manifests have improved line length handling, taking care of encoding. | ||||
@@ -674,7 +674,8 @@ public class FileUtils { | |||||
continue; | continue; | ||||
} else if ("..".equals(thisToken)) { | } else if ("..".equals(thisToken)) { | ||||
if (s.size() < 2) { | if (s.size() < 2) { | ||||
throw new BuildException("Cannot resolve path " + path); | |||||
// Cannot resolve it, so skip it. | |||||
return new File(path); | |||||
} | } | ||||
s.pop(); | s.pop(); | ||||
} else { // plain component | } else { // plain component | ||||
@@ -193,12 +193,9 @@ public class FileUtilsTest extends TestCase { | |||||
assertEquals(localize("/1/2/3/4"), | assertEquals(localize("/1/2/3/4"), | ||||
FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "..\\../5/..\\./2/./3/6\\../4").getPath()); | FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "..\\../5/..\\./2/./3/6\\../4").getPath()); | ||||
try { | |||||
FILE_UTILS.resolveFile(new File(localize("/1")), "../../b"); | |||||
fail("successfully crawled beyond the filesystem root"); | |||||
} catch (BuildException e) { | |||||
// Expected Exception caught | |||||
} | |||||
assertEquals("meaningless result but no exception", | |||||
new File(localize("/1/../../b")), | |||||
FILE_UTILS.resolveFile(new File(localize("/1")), "../../b")); | |||||
} | } | ||||
@@ -315,12 +312,9 @@ public class FileUtilsTest extends TestCase { | |||||
// Expected exception caught | // Expected exception caught | ||||
} | } | ||||
try { | |||||
FILE_UTILS.normalize(localize("/1/../../b")); | |||||
fail("successfully crawled beyond the filesystem root"); | |||||
} catch (BuildException e) { | |||||
// Expected exception caught | |||||
} | |||||
assertEquals("will not go outside FS root (but will not throw an exception either)", | |||||
new File(localize("/1/../../b")), | |||||
FILE_UTILS.normalize(localize("/1/../../b"))); | |||||
} | } | ||||
/** | /** | ||||