You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2015/03/28 19:58:16 UTC

svn commit: r1669822 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

Author: bodewig
Date: Sat Mar 28 18:58:16 2015
New Revision: 1669822

URL: http://svn.apache.org/r1669822
Log:
COMPRESS-312 normalize filename in TarArchiveEntry's (File, String) constructor

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1669822&r1=1669821&r2=1669822&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sat Mar 28 18:58:16 2015
@@ -54,6 +54,10 @@ breaks backwards compatibility for code
 This also changes the superclass of ZCompressorInputStream.    
 ">
 
+      <action issue="COMPRESS-312" type="fix" date="2015-03-28">
+        TarArchiveEntry's constructor with a File and a String arg
+        didn't normalize the name.
+      </action>
       <action issue="COMPRESS-308" type="fix" date="2015-02-20">
         ZipEncodingHelper no longer reads system properties directly
         to determine the default charset.

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1669822&r1=1669821&r2=1669822&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Sat Mar 28 18:58:16 2015
@@ -263,7 +263,7 @@ public class TarArchiveEntry implements
      * @param file The file that the entry represents.
      */
     public TarArchiveEntry(File file) {
-        this(file, normalizeFileName(file.getPath(), false));
+        this(file, file.getPath());
     }
 
     /**
@@ -274,23 +274,24 @@ public class TarArchiveEntry implements
      * @param fileName the name to be used for the entry.
      */
     public TarArchiveEntry(File file, String fileName) {
+        String normalizedName = normalizeFileName(fileName, false);
         this.file = file;
 
         if (file.isDirectory()) {
             this.mode = DEFAULT_DIR_MODE;
             this.linkFlag = LF_DIR;
 
-            int nameLength = fileName.length();
-            if (nameLength == 0 || fileName.charAt(nameLength - 1) != '/') {
-                this.name = fileName + "/";
+            int nameLength = normalizedName.length();
+            if (nameLength == 0 || normalizedName.charAt(nameLength - 1) != '/') {
+                this.name = normalizedName + "/";
             } else {
-                this.name = fileName;
+                this.name = normalizedName;
             }
         } else {
             this.mode = DEFAULT_FILE_MODE;
             this.linkFlag = LF_NORMAL;
             this.size = file.length();
-            this.name = fileName;
+            this.name = normalizedName;
         }
 
         this.modTime = file.lastModified() / MILLIS_PER_SECOND;