Skip to content

Commit

Permalink
allow setting maximum decompressed size for ZLibCompressedStringReade…
Browse files Browse the repository at this point in the history
…r and GZipCompressedStringReader
  • Loading branch information
KurtThiemann committed Aug 13, 2024
1 parent e9afc03 commit 862406e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/IO/Reader/GZipCompressedStringReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class GZipCompressedStringReader extends StringReader
/**
* @throws Exception
*/
public function __construct(string $data, int $format)
public function __construct(string $data, int $format, int $maxDecompressedSize = 0)
{
if (($uncompressed = @gzdecode($data)) === false) {
if (($uncompressed = @gzdecode($data, $maxDecompressedSize)) === false) {
throw new Exception("Invalid GZip data");
}
parent::__construct($uncompressed, $format);
Expand Down
4 changes: 2 additions & 2 deletions src/IO/Reader/ZLibCompressedStringReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class ZLibCompressedStringReader extends StringReader
/**
* @throws Exception
*/
public function __construct(string $data, int $format)
public function __construct(string $data, int $format, int $maxDecompressedSize = 0)
{
if (($uncompressed = @zlib_decode($data)) === false) {
if (($uncompressed = @zlib_decode($data, $maxDecompressedSize)) === false) {
throw new Exception("Invalid ZLib data");
}
parent::__construct($uncompressed, $format);
Expand Down

0 comments on commit 862406e

Please sign in to comment.