Author: bodewig
Date: Thu Jan  2 14:01:45 2014
New Revision: 1554808

URL: http://svn.apache.org/r1554808
Log:
Don't use leading slashes for patterns in zipfileset.  PR 53949

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/manual/Types/tarfileset.html
    ant/core/trunk/manual/Types/zipfileset.html
    ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java

Modified: ant/core/trunk/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1554808&r1=1554807&r2=1554808&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Jan  2 14:01:45 2014
@@ -12,6 +12,14 @@ Changes that could break older environme
    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:
 -----------
 

Modified: ant/core/trunk/manual/Types/tarfileset.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/manual/Types/tarfileset.html?rev=1554808&r1=1554807&r2=1554808&view=diff
==============================================================================
--- ant/core/trunk/manual/Types/tarfileset.html (original)
+++ ant/core/trunk/manual/Types/tarfileset.html Thu Jan  2 14:01:45 2014
@@ -44,7 +44,9 @@ is used, the tarfileset is populated wit
 </ul>
 <p><code>&lt;tarfileset&gt;</code> supports all attributes of <code>&lt;<a
  href="fileset.html">fileset</a>&gt;</code>
-in addition to those listed below.<br>
+ 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.
 </p>
 <p>A tarfileset can be defined with the <span style="font-style:
 italic;">id </span>attribute and referred to with the <span

Modified: ant/core/trunk/manual/Types/zipfileset.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/manual/Types/zipfileset.html?rev=1554808&r1=1554807&r2=1554808&view=diff
==============================================================================
--- ant/core/trunk/manual/Types/zipfileset.html (original)
+++ ant/core/trunk/manual/Types/zipfileset.html Thu Jan  2 14:01:45 2014
@@ -42,8 +42,10 @@ is used, the zipfileset is populated wit
 </ul>
 <p><code>&lt;zipfileset&gt;</code> supports all attributes of <code>&lt;<a
  href="fileset.html">fileset</a>&gt;</code>
-in addition to those listed below.<br>
-</p>
+ 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.</p>
+
 <p>Since Ant 1.6, a zipfileset can be defined with the <span
  style="font-style: italic;">id </span>attribute and referred to with
 the <span style="font-style: italic;">refid</span> attribute.<br>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java?rev=1554808&r1=1554807&r2=1554808&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java 
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java Thu 
Jan  2 14:01:45 2014
@@ -255,8 +255,14 @@ public abstract class ArchiveScanner ext
      *         <code>false</code> 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);
     }
 


Reply via email to