Browse Source

Don't use leading slashes for patterns in zipfileset. PR 53949

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1554808 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
bfa0ded769
4 changed files with 23 additions and 5 deletions
  1. +8
    -0
      WHATSNEW
  2. +3
    -1
      manual/Types/tarfileset.html
  3. +4
    -2
      manual/Types/zipfileset.html
  4. +8
    -2
      src/main/org/apache/tools/ant/types/ArchiveScanner.java

+ 8
- 0
WHATSNEW View File

@@ -12,6 +12,14 @@ Changes that could break older environments:
must now explicitly set the prefixValues attribute to true. must now explicitly set the prefixValues attribute to true.
Bugzilla Report 54769 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: Fixed bugs:
----------- -----------




+ 3
- 1
manual/Types/tarfileset.html View File

@@ -44,7 +44,9 @@ is used, the tarfileset is populated with filesystem files found under <span
</ul> </ul>
<p><code>&lt;tarfileset&gt;</code> supports all attributes of <code>&lt;<a <p><code>&lt;tarfileset&gt;</code> supports all attributes of <code>&lt;<a
href="fileset.html">fileset</a>&gt;</code> 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>
<p>A tarfileset can be defined with the <span style="font-style: <p>A tarfileset can be defined with the <span style="font-style:
italic;">id </span>attribute and referred to with the <span italic;">id </span>attribute and referred to with the <span


+ 4
- 2
manual/Types/zipfileset.html View File

@@ -42,8 +42,10 @@ is used, the zipfileset is populated with filesystem files found under <span
</ul> </ul>
<p><code>&lt;zipfileset&gt;</code> supports all attributes of <code>&lt;<a <p><code>&lt;zipfileset&gt;</code> supports all attributes of <code>&lt;<a
href="fileset.html">fileset</a>&gt;</code> 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 <p>Since Ant 1.6, a zipfileset can be defined with the <span
style="font-style: italic;">id </span>attribute and referred to with style="font-style: italic;">id </span>attribute and referred to with
the <span style="font-style: italic;">refid</span> attribute.<br> the <span style="font-style: italic;">refid</span> attribute.<br>


+ 8
- 2
src/main/org/apache/tools/ant/types/ArchiveScanner.java View File

@@ -255,8 +255,14 @@ public abstract class ArchiveScanner extends DirectoryScanner {
* <code>false</code> otherwise. * <code>false</code> otherwise.
*/ */
public boolean match(String path) { 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); return isIncluded(vpath) && !isExcluded(vpath);
} }




Loading…
Cancel
Save