From 400fa878e66c1be416583d06e66eb6ccd9af5ff5 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 8 Mar 2013 18:55:49 -0500 Subject: [PATCH] Verifying that symlink target may be absolute. --- core/src/main/java/hudson/Util.java | 2 +- core/src/test/java/hudson/UtilTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 1d9cfad0c0..12a0925984 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -1023,7 +1023,7 @@ public class Util { * @param baseDir * Base directory to resolve the 'symlinkPath' parameter. * @param targetPath - * The file that the symlink should point to. + * The file that the symlink should point to. Usually relative to {@code baseDir} but may instead be an absolute path. * @param symlinkPath * Where to create a symlink in (relative to {@code baseDir}) */ diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index dc1904cb5e..9deccaa54f 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -187,6 +187,14 @@ public class UtilTest { // JENKINS-12331: either a bug in createSymlink or this isn't supposed to work: //assertTrue(Util.isSymlink(new File(d,"anotherDir/link"))); + + File external = File.createTempFile("something", ""); + try { + Util.createSymlink(d, external.getAbsolutePath(), "outside", l); + assertEquals(external.getAbsolutePath(), Util.resolveSymlink(new File(d, "outside"))); + } finally { + assertTrue(external.delete()); + } } finally { Util.deleteRecursive(d); }