Add support for various deflate compression levels#309
Add support for various deflate compression levels#309schlessera merged 4 commits intoWordPress:developfrom
Conversation
rmccue
left a comment
There was a problem hiding this comment.
This also needs tests in the Encoding.php suite.
library/Requests.php
Outdated
| if (substr($data, 0, 2) !== "\x1f\x8b" && substr($data, 0, 2) !== "\x78\x9c") { | ||
| // All valid deflate, gzip header magic markers | ||
| $valid_magic = array("\x1f\x8b", "\x78\x01", "\x78\x5e", "\x78\x9c", "\x78\xda"); | ||
| if (!in_array(substr($data, 0, 2), $valid_magic)) { |
There was a problem hiding this comment.
This needs to use the $strict parameter to in_array, but otherwise looks good.
There was a problem hiding this comment.
Fixed in follow up commit. Tests included.
Codecov Report
@@ Coverage Diff @@
## master #309 +/- ##
============================================
+ Coverage 92.11% 92.11% +<.01%
+ Complexity 760 759 -1
============================================
Files 21 21
Lines 1762 1763 +1
============================================
+ Hits 1623 1624 +1
Misses 139 139
Continue to review full report at Codecov.
|
|
Added strict |
|
@schlessera I've just been looking at this PR. This seems like a good change. What do you think ? To get this ready to merge, IMO, the following actions are needed:
|
Different compression levels yield a specific second byte in the magic header for the deflate encoding. All of them can be decoded by the same functions without any issues. Let them through, as they've been seen in the wild. Fixes WordPress#301
6815ae6 to
746b8f0
Compare
|
I've made the changes as per the above comment. This PR is now ready for review/merge. |
746b8f0 to
dea73d2
Compare
Strict check magic zlib magic markers. Add zlib compression level tests. ~~Enable encoding tests, these were not included in the test suite.~~
dea73d2 to
53f025b
Compare
... and document the source and what the marker is indicating. Includes switching to using `isset()` instead of `in_array()` for a tiny performance boost.
53f025b to
c13e6bc
Compare
| * All (known) valid deflate, gzip header magic markers. | ||
| * | ||
| * These markers related to different compression levels. | ||
| * These markers relate to different compression levels. |
|
Thanks for the PR, @soulseekah ! |
Different compression levels yield a specific second byte in the magic
header for the deflate encoding. All of them can be decoded by the same
functions without any issues. Let them through, as they've been seen in
the wild.
Fixes #301