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/10/06 05:38:40 UTC

commons-compress git commit: COMPRESS-324 be more lenient when detecting GNU tar extensions

Repository: commons-compress
Updated Branches:
  refs/heads/master d85561d90 -> 1930eed89


COMPRESS-324 be more lenient when detecting GNU tar extensions


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/1930eed8
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/1930eed8
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/1930eed8

Branch: refs/heads/master
Commit: 1930eed89459d1ea726762e362143a5aa2ccaeb4
Parents: d85561d
Author: Stefan Bodewig <st...@innoq.com>
Authored: Tue Oct 6 05:37:28 2015 +0200
Committer: Stefan Bodewig <st...@innoq.com>
Committed: Tue Oct 6 05:37:28 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                          |   5 +++++
 .../compress/archivers/tar/TarArchiveEntry.java  |   6 ++----
 .../archivers/tar/TarArchiveInputStreamTest.java |  18 ++++++++++++++++++
 src/test/resources/COMPRESS-324.tar              | Bin 0 -> 10240 bytes
 4 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/1930eed8/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 18c6cf8..b6adccf 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,6 +44,11 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
     <release version="1.11" date="not released, yet"
              description="Release 1.11">
+      <action issue="COMPRESS-324" type="fix" date="2015-10-06">
+        TarArchiveOutputStream will now recognize GNU long name and
+        link entries even if the special entry has a different name
+        than GNU tar uses itself.
+      </action>
       <action issue="COMPRESS-321" type="fix" date="2015-08-22">
         ArrayIndexOutOfBoundsException when InfoZIP type 7875 extra
         fields are read from the central directory.

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/1930eed8/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index cdbc80f..96bb3ee 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -728,8 +728,7 @@ public class TarArchiveEntry implements TarConstants, ArchiveEntry {
      * @return true if this is a long name extension provided by GNU tar
      */
     public boolean isGNULongLinkEntry() {
-        return linkFlag == LF_GNUTYPE_LONGLINK
-            && name.equals(GNU_LONGLINK);
+        return linkFlag == LF_GNUTYPE_LONGLINK;
     }
 
     /**
@@ -738,8 +737,7 @@ public class TarArchiveEntry implements TarConstants, ArchiveEntry {
      * @return true if this is a long name extension provided by GNU tar
      */
     public boolean isGNULongNameEntry() {
-        return linkFlag == LF_GNUTYPE_LONGNAME
-            && name.equals(GNU_LONGLINK);
+        return linkFlag == LF_GNUTYPE_LONGNAME;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/1930eed8/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
index ca53b8b..862e02b 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
@@ -256,6 +256,24 @@ public class TarArchiveInputStreamTest {
         tis.close();
     }
 
+    /**
+     * @link "https://issues.apache.org/jira/browse/COMPRESS-324"
+     */
+    @Test
+    public void shouldReadGNULongNameEntryWithWrongName() throws Exception {
+        TarArchiveInputStream is = getTestStream("/COMPRESS-324.tar");
+        try {
+            TarArchiveEntry entry = is.getNextTarEntry();
+            assertEquals("1234567890123456789012345678901234567890123456789012345678901234567890"
+                         + "1234567890123456789012345678901234567890123456789012345678901234567890"
+                         + "1234567890123456789012345678901234567890123456789012345678901234567890"
+                         + "1234567890123456789012345678901234567890.txt",
+                         entry.getName());
+        } finally {
+            is.close();
+        }
+    }
+
     private TarArchiveInputStream getTestStream(String name) {
         return new TarArchiveInputStream(
                 TarArchiveInputStreamTest.class.getResourceAsStream(name));

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/1930eed8/src/test/resources/COMPRESS-324.tar
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-324.tar b/src/test/resources/COMPRESS-324.tar
new file mode 100644
index 0000000..902fcca
Binary files /dev/null and b/src/test/resources/COMPRESS-324.tar differ