[ 
https://issues.apache.org/jira/browse/COMPRESS-538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pritesh updated COMPRESS-538:
-----------------------------
    Description: 
When creating a zip file using 
[ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-]
 constructor each entry get an extra `Zip64ExtendedInformationExtraField` 
header which shouldn't be there.

 

The issue can be reproduced using below code sample
{code:java}
    public static void main(String[] args) throws IOException {
        // Create file
        final File file = File.createTempFile("apache_", ".zip");
        try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) {
            zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt"));
            zos.closeArchiveEntry();
        }

        // List Headers File
        final ZipFile zipFile = new ZipFile(file);
        final Enumeration<? extends ZipArchiveEntry> entries = 
zipFile.getEntries();
        while (entries.hasMoreElements()) {
            final ZipArchiveEntry entry = entries.nextElement();
            for (ZipExtraField zipExtraField : entry.getExtraFields()) {
                System.out.println("EntryName:" + entry.getName() + " Header: 
"+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present.
            }
        }
    }
{code}

  was:
When creating a zip file using 
[ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-]
 constructor each entry get an extra `Zip64ExtendedInformationExtraField` 
header which shouldn't be there. 

{code:java}
    public static void main(String[] args) throws IOException {
        // Create file
        final File file = File.createTempFile("apache_", ".zip");
        try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) {
            zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt"));
            zos.closeArchiveEntry();
        }

        // List Headers File
        final ZipFile zipFile = new ZipFile(file);
        final Enumeration<? extends ZipArchiveEntry> entries = 
zipFile.getEntries();
        while (entries.hasMoreElements()) {
            final ZipArchiveEntry entry = entries.nextElement();
            for (ZipExtraField zipExtraField : entry.getExtraFields()) {
                System.out.println("EntryName:" + entry.getName() + " Header: 
"+ zipExtraField.getHeaderId().getValue());
            }
        }
    }
{code}


> ZipEntry created using ZipArchiveOutputStream(File) constructor adds 'ZIP64 
> Extended Information Extra Field' even when zip64 is not required.
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: COMPRESS-538
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-538
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.8
>            Reporter: Pritesh
>            Priority: Major
>
> When creating a zip file using 
> [ZipArchiveOutputStream(File)|https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.html#ZipArchiveOutputStream-java.io.File-]
>  constructor each entry get an extra `Zip64ExtendedInformationExtraField` 
> header which shouldn't be there.
>  
> The issue can be reproduced using below code sample
> {code:java}
>     public static void main(String[] args) throws IOException {
>         // Create file
>         final File file = File.createTempFile("apache_", ".zip");
>         try ( ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) {
>             zos.putArchiveEntry(new ZipArchiveEntry("TextFile1.txt"));
>             zos.closeArchiveEntry();
>         }
>         // List Headers File
>         final ZipFile zipFile = new ZipFile(file);
>         final Enumeration<? extends ZipArchiveEntry> entries = 
> zipFile.getEntries();
>         while (entries.hasMoreElements()) {
>             final ZipArchiveEntry entry = entries.nextElement();
>             for (ZipExtraField zipExtraField : entry.getExtraFields()) {
>                 System.out.println("EntryName:" + entry.getName() + " Header: 
> "+ zipExtraField.getHeaderId().getValue()); // Header shouldn't be present.
>             }
>         }
>     }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to