Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,10 @@ function block_sort($array1, $array2)
} else {
$apcversion = phpversion('apcu');

if ($rss[0] !== '<') {
$rss = gzdecode($rss);
}
Comment on lines +1120 to +1122
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($rss[0] !== '<') {
$rss = gzdecode($rss);
}
if (ord($rss[0]) === 0x1f && ord($rss[1]) === 0x8b) {
$rss = gzdecode($rss);
}
  • I propose to check for the magic numbers 0x1f and 0x8b to identify the data as a gzip stream. Imho, this is more precise and it allows us to pick different decompression algorithms if necessary someday.
  • A decompression failure (if gzdecode() returns false) should be handled properly. Perhaps it makes sense to do this a few lines earlier (before line 1115)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it's better to check the magic numbers. (Even better would probably to check for the content-encoding response header.)


preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match);
echo '<tr class="tr-0 center"><td>';
if (version_compare($apcversion, $match[1], '>=')) {
Expand Down