PeterAlfredLee commented on pull request #356: URL: https://github.com/apache/tika/pull/356#issuecomment-698067189
I updated a little bit with the DD signature part. This works with Compress 1.20 and works fine with this PR. ``` private InputStream forgeZipInputStream() throws IOException { // generate a zip archive in memory try (final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final ZipArchiveOutputStream zo = new ZipArchiveOutputStream(byteArrayOutputStream);){ final ZipArchiveEntry entryA = new ZipArchiveEntry("foo"); entryA.setMethod(ZipEntry.STORED); entryA.setSize(4); entryA.setCrc(0xb63cfbcdl); zo.putArchiveEntry(entryA); zo.write(new byte[] { 1, 2, 3, 4 }); zo.closeArchiveEntry(); zo.close(); final byte[] zipContent = byteArrayOutputStream.toByteArray(); final byte[] old = Arrays.copyOf(zipContent, zipContent.length); final byte[] zipContentWithDataDescriptor = new byte[zipContent.length + 16]; System.arraycopy(zipContent, 0, zipContentWithDataDescriptor, 0, 37); // modify the general purpose bit flag zipContentWithDataDescriptor[6] = (byte) 0x08; // add the Data Descriptor Signature zipContentWithDataDescriptor[37] = (byte) 0x50; zipContentWithDataDescriptor[38] = (byte) 0x4B; zipContentWithDataDescriptor[39] = (byte) 0x07; zipContentWithDataDescriptor[40] = (byte) 0x08; // copy the crc-32, compressed size and uncompressed size to the data descriptor System.arraycopy(zipContent, 14, zipContentWithDataDescriptor, 41, 12); // and copy the rest of the zip content System.arraycopy(zipContent, 37, zipContentWithDataDescriptor, 53, zipContent.length - 37); return new ByteArrayInputStream(zipContentWithDataDescriptor); } } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org