diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index e6fffb75cb2769b30890f900522f126eb46e99bd..e8ed8f0c89983fe395cf03a380d8859d1245eb1f 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -268,14 +268,19 @@ public class Util { */ //Taken from http://svn.apache.org/viewvc/maven/shared/trunk/file-management/src/main/java/org/apache/maven/shared/model/fileset/util/FileSetManager.java?view=markup public static boolean isSymlink(File file) throws IOException { - File parent = file.getParentFile(); - File canonicalFile = file.getCanonicalFile(); - - return parent != null - && (!canonicalFile.getName().equals(file.getName()) || !canonicalFile.getPath().startsWith( - parent.getCanonicalPath())); - } - + String name = file.getName(); + if (name.equals(".") || name.equals("..")) + return false; + + File fileInCanonicalParent = null; + File parentDir = file.getParentFile(); + if ( parentDir == null ) { + fileInCanonicalParent = file; + } else { + fileInCanonicalParent = new File( parentDir.getCanonicalPath(), name ); + } + return !fileInCanonicalParent.getCanonicalFile().equals( fileInCanonicalParent.getAbsoluteFile() ); + } /** * Creates a new temporary directory.