[jira] [Work logged] (COMPRESS-621) ZipFile does not support prepending additional data to the zip content

2022-12-07 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/COMPRESS-621?focusedWorklogId=831931=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-831931
 ]

ASF GitHub Bot logged work on COMPRESS-621:
---

Author: ASF GitHub Bot
Created on: 08/Dec/22 01:53
Start Date: 08/Dec/22 01:53
Worklog Time Spent: 10m 
  Work Description: garydgregory merged PR #334:
URL: https://github.com/apache/commons-compress/pull/334




Issue Time Tracking
---

Worklog Id: (was: 831931)
Time Spent: 50m  (was: 40m)

> ZipFile does not support prepending additional data to the zip content
> --
>
> Key: COMPRESS-621
> URL: https://issues.apache.org/jira/browse/COMPRESS-621
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.21
>Reporter: Glavo
>Priority: Major
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> In general, Zip files support placing arbitrary content before their body 
> without affecting their compliance.
> Here is an example:
> [https://github.com/huanghongxun/HMCL/releases/download/v3.5.2.218/HMCL-3.5.2.218.exe]
>  
> This is actually a jar file, but we prepend an exe launcher to it, so it can 
> be used both as a jar and as an exe.
> java.util.zip.ZipFile can open and read it normally, but 
> org.apache.commons.compress.archivers.zip.ZipFile can open it but cannot read 
> any entries.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (COMPRESS-621) ZipFile does not support prepending additional data to the zip content

2022-12-07 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/COMPRESS-621?focusedWorklogId=831930=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-831930
 ]

ASF GitHub Bot logged work on COMPRESS-621:
---

Author: ASF GitHub Bot
Created on: 08/Dec/22 01:53
Start Date: 08/Dec/22 01:53
Worklog Time Spent: 10m 
  Work Description: 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..."





Issue Time Tracking
---

Worklog Id: (was: 831930)
Time Spent: 40m  (was: 0.5h)

> ZipFile does not support prepending additional data to the zip content
> --
>
> Key: COMPRESS-621
> URL: https://issues.apache.org/jira/browse/COMPRESS-621
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.21
>Reporter: Glavo
>Priority: Major
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> In general, Zip files support placing arbitrary content before their body 
> without affecting their compliance.
> Here is an example:
> [https://github.com/huanghongxun/HMCL/releases/download/v3.5.2.218/HMCL-3.5.2.218.exe]
>  
> This is actually a jar file, but we prepend an exe launcher to it, so it can 
> be used both as a jar and as an exe.
> java.util.zip.ZipFile can open and read it normally, but 
> org.apache.commons.compress.archivers.zip.ZipFile can open it but cannot read 
> any entries.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (COMPRESS-621) ZipFile does not support prepending additional data to the zip content

2022-12-07 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/COMPRESS-621?focusedWorklogId=831855=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-831855
 ]

ASF GitHub Bot logged work on COMPRESS-621:
---

Author: ASF GitHub Bot
Created on: 07/Dec/22 19:00
Start Date: 07/Dec/22 19:00
Worklog Time Spent: 10m 
  Work Description: Glavo commented on PR #334:
URL: https://github.com/apache/commons-compress/pull/334#issuecomment-1341434576

   @PeterAlfredLee Can you review this PR?




Issue Time Tracking
---

Worklog Id: (was: 831855)
Time Spent: 0.5h  (was: 20m)

> ZipFile does not support prepending additional data to the zip content
> --
>
> Key: COMPRESS-621
> URL: https://issues.apache.org/jira/browse/COMPRESS-621
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.21
>Reporter: Glavo
>Priority: Major
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> In general, Zip files support placing arbitrary content before their body 
> without affecting their compliance.
> Here is an example:
> [https://github.com/huanghongxun/HMCL/releases/download/v3.5.2.218/HMCL-3.5.2.218.exe]
>  
> This is actually a jar file, but we prepend an exe launcher to it, so it can 
> be used both as a jar and as an exe.
> java.util.zip.ZipFile can open and read it normally, but 
> org.apache.commons.compress.archivers.zip.ZipFile can open it but cannot read 
> any entries.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (COMPRESS-621) ZipFile does not support prepending additional data to the zip content

2022-12-07 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/COMPRESS-621?focusedWorklogId=831777=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-831777
 ]

ASF GitHub Bot logged work on COMPRESS-621:
---

Author: ASF GitHub Bot
Created on: 07/Dec/22 14:06
Start Date: 07/Dec/22 14:06
Worklog Time Spent: 10m 
  Work Description: 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=h1_medium=referral_source=github_content=comment_campaign=pr+comments_term=The+Apache+Software+Foundation)
 Report
   > Merging 
[#334](https://codecov.io/gh/apache/commons-compress/pull/334?src=pr=desc_medium=referral_source=github_content=comment_campaign=pr+comments_term=The+Apache+Software+Foundation)
 (b1c3d8d) into 
[master](https://codecov.io/gh/apache/commons-compress/commit/821c2462d875b84f699f01b2d14250f5e1fc6a23?el=desc_medium=referral_source=github_content=comment_campaign=pr+comments_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 2518625195+9 
 Branches   4145 4146+1 
   =
   + Hits  2017620184+8 
 Misses 3412 3412   
   - Partials   1598 1599+1 
   ```
   
   
   | [Impacted 
Files](https://codecov.io/gh/apache/commons-compress/pull/334?src=pr=tree_medium=referral_source=github_content=comment_campaign=pr+comments_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=tree_medium=referral_source=github_content=comment_campaign=pr+comments_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_source=github_content=comment_campaign=pr+comments_term=The+Apache+Software+Foundation)
   




Issue Time Tracking
---

Worklog Id: (was: 831777)
Time Spent: 20m  (was: 10m)

> ZipFile does not support prepending additional data to the zip content
> --
>
> Key: COMPRESS-621
> URL: https://issues.apache.org/jira/browse/COMPRESS-621
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.21
>Reporter: Glavo
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> In general, Zip files support placing arbitrary content before their body 
> without affecting their compliance.
> Here is an example:
> [https://github.com/huanghongxun/HMCL/releases/download/v3.5.2.218/HMCL-3.5.2.218.exe]
>  
> This is actually a jar file, but we prepend an exe launcher to it, so it can 
> be used both as a jar and as an exe.
> java.util.zip.ZipFile can open and read it normally, but 
> org.apache.commons.compress.archivers.zip.ZipFile can open it but cannot read 
> any entries.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Work logged] (COMPRESS-621) ZipFile does not support prepending additional data to the zip content

2022-12-07 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/COMPRESS-621?focusedWorklogId=831776=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-831776
 ]

ASF GitHub Bot logged work on COMPRESS-621:
---

Author: ASF GitHub Bot
Created on: 07/Dec/22 14:01
Start Date: 07/Dec/22 14:01
Worklog Time Spent: 10m 
  Work Description: 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.)
   




Issue Time Tracking
---

Worklog Id: (was: 831776)
Remaining Estimate: 0h
Time Spent: 10m

> ZipFile does not support prepending additional data to the zip content
> --
>
> Key: COMPRESS-621
> URL: https://issues.apache.org/jira/browse/COMPRESS-621
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Archivers
>Affects Versions: 1.21
>Reporter: Glavo
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> In general, Zip files support placing arbitrary content before their body 
> without affecting their compliance.
> Here is an example:
> [https://github.com/huanghongxun/HMCL/releases/download/v3.5.2.218/HMCL-3.5.2.218.exe]
>  
> This is actually a jar file, but we prepend an exe launcher to it, so it can 
> be used both as a jar and as an exe.
> java.util.zip.ZipFile can open and read it normally, but 
> org.apache.commons.compress.archivers.zip.ZipFile can open it but cannot read 
> any entries.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)