commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1427363 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
Date Tue, 01 Jan 2013 11:05:48 GMT
Author: bodewig
Date: Tue Jan  1 11:05:48 2013
New Revision: 1427363

URL: http://svn.apache.org/viewvc?rev=1427363&view=rev
Log:
COMPRESS-208 properly detect split ZIP files

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=1427363&r1=1427362&r2=1427363&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Tue Jan  1 11:05:48 2013
@@ -515,7 +515,10 @@ public class ZipArchiveInputStream exten
         }
 
         return checksig(signature, ZipArchiveOutputStream.LFH_SIG) // normal file
-            || checksig(signature, ZipArchiveOutputStream.EOCD_SIG); // empty zip
+            || checksig(signature, ZipArchiveOutputStream.EOCD_SIG) // empty zip
+            || checksig(signature, ZipArchiveOutputStream.DD_SIG) // split zip
+            || checksig(signature,
+                        ZipLong.SINGLE_SEGMENT_SPLIT_MARKER.getBytes());
     }
 
     private static boolean checksig(byte[] signature, byte[] expected){

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java?rev=1427363&r1=1427362&r2=1427363&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
Tue Jan  1 11:05:48 2013
@@ -26,6 +26,7 @@ import java.io.ByteArrayInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
 import org.junit.Test;
 
 public class ArchiveStreamFactoryTest {
@@ -79,4 +80,22 @@ public class ArchiveStreamFactoryTest {
         }
     }
 
+    /**
+     * Test case for 
+     * <a href="https://issues.apache.org/jira/browse/COMPRESS-208"
+     * >COMPRESS-208</a>.
+     */
+    @Test
+    public void skipsPK00Prefix() throws Exception {
+        InputStream is = null;
+        try {
+            is = new BufferedInputStream(new FileInputStream("src/test/resources/COMPRESS-208.zip"));
+            ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(is);
+            assertTrue(ais instanceof ZipArchiveInputStream);
+        } finally {
+            if (is != null) {
+                is.close();
+            }
+        }
+    }
 }



Mime
View raw message