-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
This is from a discussion as part of dotnet/Open-XML-SDK#1443
there is no way to configure zip headers general purpose flags bit 1 and 2 via ZipArchive implementation. According to ISO 29500-2 OPC standard bit 1 and 2 are mandatory and reflect the applied zip compression.
Here is the meaning of those bits for deflate (as is used here): https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE_6.2.0.txt
(For Methods 8 and 9 - Deflating) Bit 2 Bit 1 0 0 Normal (-en) compression option was used. 0 1 Maximum (-exx/-ex) compression option was used. 1 0 Fast (-ef) compression option was used. 1 1 Super Fast (-es) compression option was used. Note: Bits 1 and 2 are undefined if the compression method is any other.
These bits used to be set with a meaningful mapping via Open-XML-SDK when using .net framework
In the NETFx WindowsBase compression implementation this was set here:
https://referencesource.microsoft.com/#WindowsBase/Base/MS/Internal/IO/Zip/ZipIOLocalFileHeader.cs,308
Based on the following mapping:
https://referencesource.microsoft.com/#WindowsBase/Base/System/IO/Packaging/ZipPackage.cs,490
I´m suggesting that the ZipArchive implementation either set bits 1 & 2 as some mapping from CompressionLevel, or expose and API so that callers can specify the value for these bits.
Reproduction Steps
Using the Open XML SDK to reproduce this can be simple:
using System.IO.Packaging;
// Create a document by supplying the filepath.
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(args[0], >WordprocessingDocumentType.Document))...
wordDocument.Save();
Target .Net 7.0, 6.0, 5.0
Expected behavior
the ZipArchive implementation either set bits 1 & 2 as some mapping from CompressionLevel, or expose and API so that callers can specify the value for these bits.
Actual behavior
No means to set bits 1 & 2 at all
Regression?
I verified that .Net Framework maps CompressionLevel and turns on bit 1 & 2 in the same scenario with the test code above.
Known Workarounds
No response
Configuration
No response
Other information
No response