Upgrade to 3.7.1
This commit is contained in:
@@ -16,57 +16,57 @@ use Kirby\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class Svgz extends Svg
|
||||
{
|
||||
/**
|
||||
* Sanitizes the given string
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the file couldn't be parsed or recompressed
|
||||
*/
|
||||
public static function sanitize(string $string): string
|
||||
{
|
||||
$string = static::uncompress($string);
|
||||
$string = parent::sanitize($string);
|
||||
$string = @gzencode($string);
|
||||
/**
|
||||
* Sanitizes the given string
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the file couldn't be parsed or recompressed
|
||||
*/
|
||||
public static function sanitize(string $string): string
|
||||
{
|
||||
$string = static::uncompress($string);
|
||||
$string = parent::sanitize($string);
|
||||
$string = @gzencode($string);
|
||||
|
||||
if (is_string($string) !== true) {
|
||||
throw new InvalidArgumentException('Could not recompress gzip data'); // @codeCoverageIgnore
|
||||
}
|
||||
if (is_string($string) !== true) {
|
||||
throw new InvalidArgumentException('Could not recompress gzip data'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates file contents
|
||||
*
|
||||
* @param string $string
|
||||
* @return void
|
||||
*
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the file couldn't be parsed
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the file didn't pass validation
|
||||
*/
|
||||
public static function validate(string $string): void
|
||||
{
|
||||
parent::validate(static::uncompress($string));
|
||||
}
|
||||
/**
|
||||
* Validates file contents
|
||||
*
|
||||
* @param string $string
|
||||
* @return void
|
||||
*
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the file couldn't be parsed
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the file didn't pass validation
|
||||
*/
|
||||
public static function validate(string $string): void
|
||||
{
|
||||
parent::validate(static::uncompress($string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uncompresses the SVGZ data
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
protected static function uncompress(string $string): string
|
||||
{
|
||||
// only support uncompressed files up to 10 MB to
|
||||
// prevent gzip bombs from crashing the process
|
||||
$string = @gzdecode($string, 10000000);
|
||||
/**
|
||||
* Uncompresses the SVGZ data
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
protected static function uncompress(string $string): string
|
||||
{
|
||||
// only support uncompressed files up to 10 MB to
|
||||
// prevent gzip bombs from crashing the process
|
||||
$string = @gzdecode($string, 10000000);
|
||||
|
||||
if (is_string($string) !== true) {
|
||||
throw new InvalidArgumentException('Could not uncompress gzip data');
|
||||
}
|
||||
if (is_string($string) !== true) {
|
||||
throw new InvalidArgumentException('Could not uncompress gzip data');
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user