Repository navigation
Conversation
Gzip and Bzip2 treated an empty() decompression result as failure, so valid archives of an empty file or of a file containing "0" threw "Unable to decompress data". bzdecompress() also returns a negative error code for some corrupt input, which empty() did not catch, so the code was written to the destination as text. Check for false (gzinflate) and for a non-string result (bzdecompress) instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 12, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Gzip::extract()andBzip2::extract()checked the decompressed data withempty($buffer).empty()is also true for''and"0", so valid archives of an empty file or of a file containing just0threwRuntimeException('Unable to decompress data')(gzencode(''),gzencode('0'),bzcompress('0'), …). In the other direction,bzdecompress()returns a negative error code (e.g.-5) for some corrupt input;empty()did not catch that, so the error code was written to the destination file as text.The check is now
$buffer === falseforgzinflate()and!is_string($buffer)forbzdecompress().Testing Instructions
New tests in
GzipTestandBzip2Test:testExtractFalsyContent(data provider: empty file, file with0) fails on4.x-devwith "Unable to decompress data" and passes with this PR.testExtractCorruptData: for bzip2,4.x-devwrites-5into the destination instead of throwing; with this PR it throws and writes nothing. The gzip variant guards the existing behaviour.vendor/bin/phpunit, phpcs onsrc/and PHPStan are clean.Documentation Changes Required
None. The docs do not describe this edge case; the change makes these archives behave like any other.
🤖 Generated with Claude Code