From af8f48729637667b2c4217fb9a288b82f89b2cc3 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 24 Jul 2008 02:00:38 +0000 Subject: [PATCH] added error diagnostics git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10979 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/FilePath.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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();