From 727efac4dfb62b0f7e6e91b53aebbc6ae741eefc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 13 Oct 2020 12:13:22 +0200 Subject: [PATCH] Convert exceptions during stack trace parsing to InvalidArgumentException --- .../files/lib/util/ExceptionLogUtil.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/util/ExceptionLogUtil.class.php b/wcfsetup/install/files/lib/util/ExceptionLogUtil.class.php index 4090a7483d..36162b1c7d 100644 --- a/wcfsetup/install/files/lib/util/ExceptionLogUtil.class.php +++ b/wcfsetup/install/files/lib/util/ExceptionLogUtil.class.php @@ -1,5 +1,6 @@ match($entry)) { - throw new \InvalidArgumentException('The given entry is malformed'); + throw new \InvalidArgumentException('The given entry is malformed.'); } $matches = $regex->getMatches(); $chainRegex->match($matches['chain'], true, Regex::ORDER_MATCH_BY_SET); @@ -75,10 +76,20 @@ final class ExceptionLogUtil { $item['information'] = null; } else { - $item['information'] = unserialize(base64_decode($item['information']), ['allowed_classes' => false]); + try { + $item['information'] = unserialize(base64_decode($item['information']), ['allowed_classes' => false]); + } + catch (SystemException $e) { + throw new \InvalidArgumentException('The additional information section of the given entry is malformed.', 0, $e); + } } - $item['stack'] = JSON::decode($item['stack']); + try { + $item['stack'] = JSON::decode($item['stack']); + } + catch (SystemException $e) { + throw new \InvalidArgumentException('The stack trace of the given entry is malformed.', 0, $e); + } return $item; }, $chainRegex->getMatches()); -- 2.20.1