Author: jglick Date: Thu Aug 17 13:23:44 2006 New Revision: 432379 URL: http://svn.apache.org/viewvc?rev=432379&view=rev Log: #40281: "Cannot resolve path" error thrown gratuitously.
Modified: ant/core/trunk/WHATSNEW ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java ant/core/trunk/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=432379&r1=432378&r2=432379&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Thu Aug 17 13:23:44 2006 @@ -102,6 +102,10 @@ 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. * Manifests have improved line length handling, taking care of encoding. Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java?rev=432379&r1=432378&r2=432379&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java Thu Aug 17 13:23:44 2006 @@ -674,7 +674,8 @@ continue; } else if ("..".equals(thisToken)) { if (s.size() < 2) { - throw new BuildException("Cannot resolve path " + path); + // Cannot resolve it, so skip it. + return new File(path); } s.pop(); } else { // plain component Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java?rev=432379&r1=432378&r2=432379&view=diff ============================================================================== --- ant/core/trunk/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java (original) +++ ant/core/trunk/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java Thu Aug 17 13:23:44 2006 @@ -193,12 +193,9 @@ assertEquals(localize("/1/2/3/4"), 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 @@ // 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"))); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]