You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2018/07/03 07:45:32 UTC
ant git commit: use getParent in isLeadingPath rather than string
comparisons
Repository: ant
Updated Branches:
refs/heads/1.9.x 4987c2aac -> 5addfa631
use getParent in isLeadingPath rather than string comparisons
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/5addfa63
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/5addfa63
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/5addfa63
Branch: refs/heads/1.9.x
Commit: 5addfa6319faeea99afb07ff361f6187be85806e
Parents: 4987c2a
Author: Stefan Bodewig <bo...@apache.org>
Authored: Tue Jul 3 09:44:50 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Tue Jul 3 09:44:50 2018 +0200
----------------------------------------------------------------------
.../org/apache/tools/ant/util/FileUtils.java | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/5addfa63/src/main/org/apache/tools/ant/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java
index 900b65b..03b8d81 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -1227,17 +1227,15 @@ public class FileUtils {
if (!resolveSymlinks) {
return isLeadingPath(leading, path);
}
- String l = leading.getCanonicalPath();
- String p = path.getCanonicalPath();
- if (l.equals(p)) {
- return true;
- }
- // ensure that l ends with a /
- // so we never think /foo was a parent directory of /foobar
- if (!l.endsWith(File.separator)) {
- l += File.separator;
- }
- return p.startsWith(l);
+ final File l = leading.getCanonicalFile();
+ File p = path.getCanonicalFile();
+ do {
+ if (l.equals(p)) {
+ return true;
+ }
+ p = p.getParentFile();
+ } while (p != null);
+ return false;
}
/**