From 94d162d6edf566cc2d1452ebf64ec02aeaca71e5 Mon Sep 17 00:00:00 2001 From: jerrm Date: Sun, 22 Nov 2020 14:03:16 -0500 Subject: [PATCH 1/3] only decompress with proper content-encoding header --- library/Requests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Requests.php b/library/Requests.php index 997bfa84e..ffcd6ae43 100644 --- a/library/Requests.php +++ b/library/Requests.php @@ -676,7 +676,7 @@ protected static function parse_response($headers, $url, $req_headers, $req_data $return->body = self::decode_chunked($return->body); unset($return->headers['transfer-encoding']); } - if (isset($return->headers['content-encoding'])) { + if (isset($return->headers['content-encoding']) && !empty(array_intersect(explode(',', strtolower($return->headers['content-encoding'])), array('gzip','x-gzip','deflate','compress','x-compress')))) { $return->body = self::decompress($return->body); } From 1b349ac1ca23c0f844d409eaa228f3e05508ec01 Mon Sep 17 00:00:00 2001 From: jerrm Date: Sun, 22 Nov 2020 14:53:33 -0500 Subject: [PATCH 2/3] travis ci style and php compatibility fixes --- library/Requests.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/Requests.php b/library/Requests.php index ffcd6ae43..3ceed43f0 100644 --- a/library/Requests.php +++ b/library/Requests.php @@ -676,8 +676,11 @@ protected static function parse_response($headers, $url, $req_headers, $req_data $return->body = self::decode_chunked($return->body); unset($return->headers['transfer-encoding']); } - if (isset($return->headers['content-encoding']) && !empty(array_intersect(explode(',', strtolower($return->headers['content-encoding'])), array('gzip','x-gzip','deflate','compress','x-compress')))) { - $return->body = self::decompress($return->body); + if (isset($return->headers['content-encoding'])) { + $compressed_encoding = array_intersect(explode(',', strtolower($return->headers['content-encoding'])), array('gzip', 'x-gzip', 'deflate', 'compress', 'x-compress',)); + if (!empty($compressed_encoding)) { + $return->body = self::decompress($return->body); + } } //fsockopen and cURL compatibility From 001a345002b2d05662a091a514e92e8a6026b2bd Mon Sep 17 00:00:00 2001 From: jerrm Date: Sun, 22 Nov 2020 15:13:59 -0500 Subject: [PATCH 3/3] hopefully last ci style fix --- library/Requests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Requests.php b/library/Requests.php index 3ceed43f0..731db0288 100644 --- a/library/Requests.php +++ b/library/Requests.php @@ -677,7 +677,7 @@ protected static function parse_response($headers, $url, $req_headers, $req_data unset($return->headers['transfer-encoding']); } if (isset($return->headers['content-encoding'])) { - $compressed_encoding = array_intersect(explode(',', strtolower($return->headers['content-encoding'])), array('gzip', 'x-gzip', 'deflate', 'compress', 'x-compress',)); + $compressed_encoding = array_intersect(explode(',', strtolower($return->headers['content-encoding'])), array('gzip', 'x-gzip', 'deflate', 'compress', 'x-compress')); if (!empty($compressed_encoding)) { $return->body = self::decompress($return->body); }