diff --git a/WHATSNEW b/WHATSNEW index a8c62f44c..e093b0538 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -12,6 +12,14 @@ Changes that could break older environments: must now explicitly set the prefixValues attribute to true. Bugzilla Report 54769 + * when matching an entry of a zip/tarfileset against a pattern a + leading slash will be stripped from the entry name. Most archive + don't contain paths with leading slashes anyway. + This may cause include/exclude patterns that start with a / to stop + matching anything. Such patterns only used to work by accident and + only on platforms with multiple file syste roots. + Bugzilla Report 53949 + Fixed bugs: ----------- diff --git a/manual/Types/tarfileset.html b/manual/Types/tarfileset.html index 6eb416160..34355b8d8 100644 --- a/manual/Types/tarfileset.html +++ b/manual/Types/tarfileset.html @@ -44,7 +44,9 @@ is used, the tarfileset is populated with filesystem files found under

<tarfileset> supports all attributes of <fileset> -in addition to those listed below.
+ in addition to those listed below. Note that tar archives in general + don't contain entries with leading slashes so you shouldn't use + include/exclude patterns that start with slashes either.

A tarfileset can be defined with the id attribute and referred to with the

<zipfileset> supports all attributes of <fileset> -in addition to those listed below.
-

+ in addition to those listed below. Note that zip archives in general + don't contain entries with leading slashes so you shouldn't use + include/exclude patterns that start with slashes either.

+

Since Ant 1.6, a zipfileset can be defined with the id attribute and referred to with the refid attribute.
diff --git a/src/main/org/apache/tools/ant/types/ArchiveScanner.java b/src/main/org/apache/tools/ant/types/ArchiveScanner.java index 67ff09c27..d587a2859 100644 --- a/src/main/org/apache/tools/ant/types/ArchiveScanner.java +++ b/src/main/org/apache/tools/ant/types/ArchiveScanner.java @@ -255,8 +255,14 @@ public abstract class ArchiveScanner extends DirectoryScanner { * false otherwise. */ public boolean match(String path) { - String vpath = path.replace('/', File.separatorChar). - replace('\\', File.separatorChar); + String vpath = path; + if (path.length() > 0) { + vpath = path.replace('/', File.separatorChar). + replace('\\', File.separatorChar); + if (vpath.charAt(0) == File.separatorChar) { + vpath = vpath.substring(1); + } + } return isIncluded(vpath) && !isExcluded(vpath); }