ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/4] ant git commit: ensure FileNameMapper implementations deal with null source names
Date Fri, 09 Feb 2018 17:50:45 GMT
ensure FileNameMapper implementations deal with null source names

https://bz.apache.org/bugzilla/show_bug.cgi?id=62076


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/a3246562
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/a3246562
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/a3246562

Branch: refs/heads/master
Commit: a3246562ff3ac48ef32d75df688bc04e22bc7dd7
Parents: 801a44a
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Fri Feb 9 18:37:58 2018 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Fri Feb 9 18:37:58 2018 +0100

----------------------------------------------------------------------
 src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java | 3 +++
 src/main/org/apache/tools/ant/types/mappers/FilterMapper.java  | 3 +++
 src/main/org/apache/tools/ant/util/FlatFileNameMapper.java     | 3 ++-
 src/main/org/apache/tools/ant/util/GlobPatternMapper.java      | 3 +++
 src/main/org/apache/tools/ant/util/RegexpPatternMapper.java    | 3 +++
 5 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/a3246562/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java b/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java
index ce8f39c..932f3ec 100644
--- a/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java
+++ b/src/main/org/apache/tools/ant/types/mappers/CutDirsMapper.java
@@ -63,6 +63,9 @@ public class CutDirsMapper implements FileNameMapper {
             throw new BuildException("dirs must be set to a positive number");
         }
         final char fileSep = File.separatorChar;
+        if (sourceFileName == null) {
+            return null;
+        }
         final String fileSepCorrected =
             sourceFileName.replace('/', fileSep).replace('\\', fileSep);
         int nthMatch = fileSepCorrected.indexOf(fileSep);

http://git-wip-us.apache.org/repos/asf/ant/blob/a3246562/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java b/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
index 501da50..9ef922e 100644
--- a/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
+++ b/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
@@ -63,6 +63,9 @@ public class FilterMapper extends FilterChain implements FileNameMapper
{
      *          the filterchain returns an empty string.
      */
     public String[] mapFileName(String sourceFileName) {
+        if (sourceFileName == null) {
+            return null;
+        }
         try {
             Reader stringReader = new StringReader(sourceFileName);
             ChainReaderHelper helper = new ChainReaderHelper();

http://git-wip-us.apache.org/repos/asf/ant/blob/a3246562/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java b/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java
index 420ccc6..04d58be 100644
--- a/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java
+++ b/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java
@@ -49,6 +49,7 @@ public class FlatFileNameMapper implements FileNameMapper {
      * @return the file name in a one-element array.
      */
     public String[] mapFileName(String sourceFileName) {
-        return new String[] {new java.io.File(sourceFileName).getName()};
+        return sourceFileName == null ? null
+            : new String[] {new java.io.File(sourceFileName).getName()};
     }
 }

http://git-wip-us.apache.org/repos/asf/ant/blob/a3246562/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/GlobPatternMapper.java b/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
index ebba54e..a0f0ca9 100644
--- a/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
+++ b/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
@@ -154,6 +154,9 @@ public class GlobPatternMapper implements FileNameMapper {
      * @return a list of converted filenames
      */
     public String[] mapFileName(String sourceFileName) {
+        if (sourceFileName == null) {
+            return null;
+        }
         String modName = modifyName(sourceFileName);
         if (fromPrefix == null
             || (sourceFileName.length() < (prefixLength + postfixLength))

http://git-wip-us.apache.org/repos/asf/ant/blob/a3246562/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java b/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
index fa620d9..6a2f4b5 100644
--- a/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
+++ b/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
@@ -114,6 +114,9 @@ public class RegexpPatternMapper implements FileNameMapper {
      *         null if the to pattern did not match
      */
     public String[] mapFileName(String sourceFileName) {
+        if (sourceFileName == null) {
+            return null;
+        }
         if (handleDirSep) {
             if (sourceFileName.indexOf("\\") != -1) {
                 sourceFileName = sourceFileName.replace('\\', '/');


Mime
View raw message