diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index ecd3b15793..9685d70f09 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -159,7 +159,7 @@ public final class FilePath implements Serializable { public FilePath(FilePath base, String rel) { this.channel = base.channel; - if(rel.startsWith("/") || DRIVE_PATTERN.matcher(rel).matches()) { + if(isAbsolute(rel)) { // absolute this.remote = rel; } else @@ -170,6 +170,10 @@ public final class FilePath implements Serializable { } } + private static boolean isAbsolute(String rel) { + return rel.startsWith("/") || DRIVE_PATTERN.matcher(rel).matches(); + } + private static final Pattern DRIVE_PATTERN = Pattern.compile("[A-Za-z]:\\\\.+"); /** @@ -613,7 +617,9 @@ public final class FilePath implements Serializable { * @return * A set of relative file names from the base directory. */ - private static String[] glob(File dir, String includes) { + private static String[] glob(File dir, String includes) throws IOException { + if(isAbsolute(includes)) + throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/CoreTypes/fileset.html for syntax"); FileSet fs = Util.createFileSet(dir,includes); DirectoryScanner ds = fs.getDirectoryScanner(new Project()); String[] files = ds.getIncludedFiles();