From 2601faa4cd1e772468817a6e4453adbb6ed2c20a Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Sun, 17 Dec 2023 11:39:08 +0100 Subject: [PATCH 1/2] Handle incorrect parameters gracefully --- src/Controller/ImageController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/ImageController.php b/src/Controller/ImageController.php index 869d58502..5ef606bfe 100644 --- a/src/Controller/ImageController.php +++ b/src/Controller/ImageController.php @@ -143,8 +143,8 @@ private function parseParameters(string $paramString): void $raw = explode('×', preg_replace('/([0-9])(x)([0-9a-z])/i', '\1×\3', $paramString)); $this->parameters = [ - 'w' => is_numeric($raw[0]) ? (int) $raw[0] : 400, - 'h' => is_numeric($raw[1]) ? (int) $raw[1] : 300, + 'w' => (isset($raw[0] && is_numeric($raw[0])) ? (int) $raw[0] : 400, + 'h' => (isset($raw[1]) && is_numeric($raw[1])) ? (int) $raw[1] : 300, 'fit' => isset($raw[2]) ? $raw[2] : $this->config->get('general/thumbnails/default_cropping', 'default'), 'location' => 'files', 'q' => (!empty($raw[2]) && 0 <= $raw[2] && $raw[2] <= 100) ? (int) $raw[2] : 80 From fc5602f264780e2c7dc75f711c125a4344a1ff2f Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Sun, 17 Dec 2023 11:42:14 +0100 Subject: [PATCH 2/2] Fix typo --- src/Controller/ImageController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/ImageController.php b/src/Controller/ImageController.php index 5ef606bfe..57f7168a8 100644 --- a/src/Controller/ImageController.php +++ b/src/Controller/ImageController.php @@ -143,7 +143,7 @@ private function parseParameters(string $paramString): void $raw = explode('×', preg_replace('/([0-9])(x)([0-9a-z])/i', '\1×\3', $paramString)); $this->parameters = [ - 'w' => (isset($raw[0] && is_numeric($raw[0])) ? (int) $raw[0] : 400, + 'w' => (isset($raw[0]) && is_numeric($raw[0])) ? (int) $raw[0] : 400, 'h' => (isset($raw[1]) && is_numeric($raw[1])) ? (int) $raw[1] : 300, 'fit' => isset($raw[2]) ? $raw[2] : $this->config->get('general/thumbnails/default_cropping', 'default'), 'location' => 'files',