mirror of
https://github.com/Intervention/image.git
synced 2025-07-31 11:00:12 +02:00
Fix bug
PHP enconters problems on some machines when is_file() in FilePathImageDecoders receive values that are longer than the maximum-path-length of the host. This fix checks if the input is in this maximum path length.
This commit is contained in:
@@ -12,12 +12,16 @@ class FilePathImageDecoder extends BinaryImageDecoder implements DecoderInterfac
|
|||||||
{
|
{
|
||||||
public function decode(mixed $input): ImageInterface|ColorInterface
|
public function decode(mixed $input): ImageInterface|ColorInterface
|
||||||
{
|
{
|
||||||
if (! is_string($input)) {
|
if (!is_string($input)) {
|
||||||
|
throw new DecoderException('Unable to decode input');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($input) > PHP_MAXPATHLEN) {
|
||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (! @is_file($input)) {
|
if (!@is_file($input)) {
|
||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
}
|
}
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
|
@@ -16,6 +16,10 @@ class FilePathImageDecoder extends BinaryImageDecoder implements DecoderInterfac
|
|||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($input) > PHP_MAXPATHLEN) {
|
||||||
|
throw new DecoderException('Unable to decode input');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!@is_file($input)) {
|
if (!@is_file($input)) {
|
||||||
throw new DecoderException('Unable to decode input');
|
throw new DecoderException('Unable to decode input');
|
||||||
@@ -25,7 +29,7 @@ class FilePathImageDecoder extends BinaryImageDecoder implements DecoderInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// decode image
|
// decode image
|
||||||
$image = parent::decode(file_get_contents($input));
|
$image = parent::decode(file_get_contents($input));
|
||||||
|
|
||||||
// set file path on origin
|
// set file path on origin
|
||||||
$image->origin()->setFilePath($input);
|
$image->origin()->setFilePath($input);
|
||||||
|
Reference in New Issue
Block a user