-
Couldn't load subscription status.
- Fork 5.2k
[release/8.0-staging] Allow setting ZipArchiveEntry general-purpose flag bits #102063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/8.0-staging] Allow setting ZipArchiveEntry general-purpose flag bits #102063
Conversation
Also changed mapping of ZipPackage's compression options, such that CompressionOption.Maximum now sets the compression level to SmallestSize, and SuperFast now sets the compression level to NoCompression. Both of these changes restore compatibility with the .NET Framework.
This test was intended to ensure that bit 11 isn't set. It was actually performing a blind comparison of the entire bit field. Other tests in System.IO.Packaging function properly.
* Updated the conditional compilation directives for the .NET Framework/Core package CompressionLevel mappings. * Specifying a CompressionMethod other than Deflate or Deflate64 will now set the compression level to NoCompression, and will write zeros to the relevant general purpose bits. * The CompressionLevel always defaulted to Optimal for new archives, but this is now explicitly set (rather than relying upon setting it to null and null-coalescing it to Optimal.) This removes a condition to test for. * Updated the test data for the CreateArchiveEntriesWithBitFlags test. If the compression level is set to NoCompression, we should expect the CompressionMethod to become Stored (which unsets the general purpose bits, returning an expected result of zero.)
* Updated mapping between general purpose bit fields and CompressionLevel. * Updated mapping from CompressionOption to CompressionLevel. * Added test to verify round-trip of CompressionOption and its setting of the general purpose bit fields.
|
Tagging subscribers to this area: @dotnet/area-system-io-compression |
|
@ViktorHofer @ericstj can I get a review and a sign-off for this servicing fix, please? |
|
As discussed offline I'd like to make sure we have a good case for taking this in servicing and that we understand the potential risk. Can we also talk about why this needs to go to both 8.0 and 6.0? |
|
The original request for a backport came from dotnet/Open-XML-SDK#1443. Re-reading the issue, I'm not sure whether the request is for the ability to set the compression level bits, the UTF8 bit or both in the general-purpose bitflags, and I've not personally got a strong opinion whether to backport or not. What's your view @maedula? |
|
Closing while we get clarity on whether this bug's impact is severe enough to justify a backport. |
@edwardneal The initial issue was about bit 11 (UTF8) being toggled and thus not being spec compliant. I consider this as a no-go and Open-XML-SDK should produce spec compliant results regardless of the .net core version. But I guess I do not understand the concern about the breaking change vs. not being spec compliant in the first place. I personally consider the compression level bits as a rather cosmetic issue and inconsistent to what the SDK produces using .net framework. |
Backport of #98278 to release/8.0-staging
/cc @carlossanlop @edwardneal
Customer Impact
Originally reported in dotnet/Open-XML-SDK.
.NET Framework allows consumers of
System.IO.Packaging.ZipPackageto useCompressionOptionto update bits 1 & 2 in the ZIP archive header's general purpose bitfield. This functionality was lost in .NET Core.OpenXML is affected because when a document like XSLX is created with our APIs, it is not compliant with the OpenXML specification ISO/IEC 29500-2, as the standard bits 1 and 2 are mandatory and are not reflecting the applied zip compression. Full discussions in #88812 and dotnet/Open-XML-SDK#1443
Specifying the
CompressionLevelofSystem.IO.Compression.ZipArchivewill now change these bits, and theZipArchive'sCompressionLevelvalue will be read from the bitfield.Regression
This PR also introduces a breaking change which is reported in detail here: dotnet/docs#40299 . Summarized, the
CompressionOptionvalues fromSystem.IO.Packagingwill map to differentCompressionLevellevels inSystem.IO.Compressiondepending if using .NET Framework or .NET Core.Testing
New tests were added to both
System.IO.CompressionandSystem.IO.Packagingto verify that setting theCompressionLevelsets the expected bits, that they can be re-read correctly and that the file data can still be decompressed correctly.Risk
Low.
Thanks to @edwardneal for fixing the issue and @maedula for the detailed report of this problem.