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 2013/01/01 11:57:24 UTC
svn commit: r1427357 - in /commons/proper/compress/trunk/src:
main/java/org/apache/commons/compress/archivers/zip/
test/java/org/apache/commons/compress/archivers/
Author: bodewig
Date: Tue Jan 1 10:57:23 2013
New Revision: 1427357
URL: http://svn.apache.org/viewvc?rev=1427357&view=rev
Log:
COMPRESS-208: skip over PK00 splitting marker which really only says 'nothing to see here'
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.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=1427357&r1=1427356&r2=1427357&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 10:57:23 2013
@@ -282,6 +282,14 @@ public class ZipArchiveInputStream exten
UnsupportedZipFeatureException(UnsupportedZipFeatureException
.Feature.SPLITTING);
}
+ if (sig.equals(ZipLong.SINGLE_SEGMENT_SPLIT_MARKER)) {
+ // The archive is not really split as only one segment was
+ // needed in the end. Just skip over the marker.
+ byte[] missedLfhBytes = new byte[4];
+ readFully(missedLfhBytes);
+ System.arraycopy(lfh, 4, lfh, 0, LFH_LEN - 4);
+ System.arraycopy(missedLfhBytes, 0, lfh, LFH_LEN - 4, 4);
+ }
}
/**
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java?rev=1427357&r1=1427356&r2=1427357&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java Tue Jan 1 10:57:23 2013
@@ -67,6 +67,17 @@ public final class ZipLong implements Cl
static final ZipLong ZIP64_MAGIC = new ZipLong(ZipConstants.ZIP64_MAGIC);
/**
+ * Marks ZIP archives that were supposed to be split or spanned
+ * but only needed a single segment in then end (so are actually
+ * neither split nor spanned).
+ *
+ * <p>This is the "PK00" prefix found in some archives.</p>
+ * @since 1.5
+ */
+ public static final ZipLong SINGLE_SEGMENT_SPLIT_MARKER =
+ new ZipLong(0X30304B50L);
+
+ /**
* Create instance from a number.
* @param value the long to store as a ZipLong
*/
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java?rev=1427357&r1=1427356&r2=1427357&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java Tue Jan 1 10:57:23 2013
@@ -116,6 +116,24 @@ public final class ZipTestCase extends A
}
/**
+ * Test case for
+ * <a href="https://issues.apache.org/jira/browse/COMPRESS-208"
+ * >COMPRESS-208</a>.
+ */
+ public void testSkipsPK00Prefix() throws Exception {
+ final File input = getFile("COMPRESS-208.zip");
+ InputStream is = new FileInputStream(input);
+ ArrayList al = new ArrayList();
+ al.add("test1.xml");
+ al.add("test2.xml");
+ try {
+ checkArchiveContent(new ZipArchiveInputStream(is), al);
+ } finally {
+ is.close();
+ }
+ }
+
+ /**
* Test case for
* <a href="https://issues.apache.org/jira/browse/COMPRESS-93"
* >COMPRESS-93</a>.