You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/12/07 14:01:36 UTC

[GitHub] [commons-compress] Glavo opened a new pull request, #334: COMPRESS-621: Fix calculation the offset of the first zip central directory entry

Glavo opened a new pull request, #334:
URL: https://github.com/apache/commons-compress/pull/334

   Since the zip central directory is at the file end, we can splice other content before the zip file.
   
   As an example, in Java 9 and above, the `$JAVA_HOME/jmods` folder contains some files with the extension `jmod`.
   The jmod file is a normal zip file, but the file starts with the four-byte magic number `0x4A 0x4D 0x01 0x00`.
   
   Another example, [Ammonite Shell](http://ammonite.io/) splices a bash shell script before the jar file, looks for Java through the bash shell script and starts itself.
   
   `java.util.zip.ZipFile` reads these files correctly, but `org.apache.commons.compress.archivers.zip.ZipFile` recognizes them as empty zip files.
   
   This PR fixes this issue and allows users to read content before the zip body.
   
   I didn't implement it for zip64 because `java.util.zip.ZipFile` didn't implement it either, and I'm not sure how it should be implemented correctly.
   
   (I seem to have missed the release date of commons-compress 1.22. This problem has a wider impact, and I hope to fix it as soon as possible.)
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-compress] codecov-commenter commented on pull request #334: COMPRESS-621: Fix calculation the offset of the first zip central directory entry

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #334:
URL: https://github.com/apache/commons-compress/pull/334#issuecomment-1341017922

   # [Codecov](https://codecov.io/gh/apache/commons-compress/pull/334?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#334](https://codecov.io/gh/apache/commons-compress/pull/334?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b1c3d8d) into [master](https://codecov.io/gh/apache/commons-compress/commit/821c2462d875b84f699f01b2d14250f5e1fc6a23?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (821c246) will **increase** coverage by `0.00%`.
   > The diff coverage is `84.61%`.
   
   ```diff
   @@            Coverage Diff            @@
   ##             master     #334   +/-   ##
   =========================================
     Coverage     80.10%   80.11%           
   - Complexity     6608     6610    +2     
   =========================================
     Files           340      340           
     Lines         25186    25195    +9     
     Branches       4145     4146    +1     
   =========================================
   + Hits          20176    20184    +8     
     Misses         3412     3412           
   - Partials       1598     1599    +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/commons-compress/pull/334?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...apache/commons/compress/archivers/zip/ZipFile.java](https://codecov.io/gh/apache/commons-compress/pull/334/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvY29tcHJlc3MvYXJjaGl2ZXJzL3ppcC9aaXBGaWxlLmphdmE=) | `78.49% <84.61%> (+0.20%)` | :arrow_up: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-compress] garydgregory merged pull request #334: COMPRESS-621: Fix calculation the offset of the first zip central directory entry

Posted by GitBox <gi...@apache.org>.
garydgregory merged PR #334:
URL: https://github.com/apache/commons-compress/pull/334


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-compress] Glavo commented on pull request #334: COMPRESS-621: Fix calculation the offset of the first zip central directory entry

Posted by GitBox <gi...@apache.org>.
Glavo commented on PR #334:
URL: https://github.com/apache/commons-compress/pull/334#issuecomment-1341434576

   @PeterAlfredLee Can you review this PR?


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [commons-compress] garydgregory commented on a diff in pull request #334: COMPRESS-621: Fix calculation the offset of the first zip central directory entry

Posted by GitBox <gi...@apache.org>.
garydgregory commented on code in PR #334:
URL: https://github.com/apache/commons-compress/pull/334#discussion_r1042844713


##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -720,6 +721,28 @@ public String getUnixSymlink(final ZipArchiveEntry entry) throws IOException {
         return null;
     }
 
+    /**
+     * Offset of the first local file header in the file.
+     *
+     * @return the length of the content before the first local file header
+     * @since 1.23
+     */
+    public long getFirstLocalFileHeaderOffset() {
+        return firstLocalFileHeaderOffset;
+    }
+
+    /**
+     * Returns an InputStream for reading the content before the first local file header.
+     *
+     * @return null if there is no content before the first local file header.
+     * Otherwise returns a stream to read the content before the first local file header.
+     * @since 1.23
+     */
+    public InputStream getContentBeforeFirstLocalFileHeader() {

Review Comment:
   See above.



##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -163,6 +163,7 @@ public class ZipFile implements Closeable {
 
     private long centralDirectoryStartDiskNumber, centralDirectoryStartRelativeOffset;
     private long centralDirectoryStartOffset;
+    private long firstLocalFileHeaderOffset = 0L;

Review Comment:
   No need to initialize to default value.



##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -720,6 +721,28 @@ public String getUnixSymlink(final ZipArchiveEntry entry) throws IOException {
         return null;
     }
 
+    /**
+     * Offset of the first local file header in the file.

Review Comment:
   Javadoc for getters should start with "Gets..."



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org