Skip to content

Commit 862406e

Browse files
committed
allow setting maximum decompressed size for ZLibCompressedStringReader and GZipCompressedStringReader
1 parent e9afc03 commit 862406e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/IO/Reader/GZipCompressedStringReader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class GZipCompressedStringReader extends StringReader
99
/**
1010
* @throws Exception
1111
*/
12-
public function __construct(string $data, int $format)
12+
public function __construct(string $data, int $format, int $maxDecompressedSize = 0)
1313
{
14-
if (($uncompressed = @gzdecode($data)) === false) {
14+
if (($uncompressed = @gzdecode($data, $maxDecompressedSize)) === false) {
1515
throw new Exception("Invalid GZip data");
1616
}
1717
parent::__construct($uncompressed, $format);

src/IO/Reader/ZLibCompressedStringReader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class ZLibCompressedStringReader extends StringReader
99
/**
1010
* @throws Exception
1111
*/
12-
public function __construct(string $data, int $format)
12+
public function __construct(string $data, int $format, int $maxDecompressedSize = 0)
1313
{
14-
if (($uncompressed = @zlib_decode($data)) === false) {
14+
if (($uncompressed = @zlib_decode($data, $maxDecompressedSize)) === false) {
1515
throw new Exception("Invalid ZLib data");
1616
}
1717
parent::__construct($uncompressed, $format);

0 commit comments

Comments
 (0)