diff --git a/system/Entity.php b/system/Entity.php index 3c8b19a7f994..e7630f972276 100644 --- a/system/Entity.php +++ b/system/Entity.php @@ -588,7 +588,8 @@ private function castAsJson($value, bool $asArray = false) $tmp = ! is_null($value) ? ($asArray ? [] : new \stdClass) : null; if (function_exists('json_decode')) { - if ((is_string($value) && (strpos($value, '[') === 0 || strpos($value, '{') === 0 || (strpos($value, '"') === 0 && strrpos($value, '"') === 0 ))) || is_numeric($value)) + $strlen = is_strimg($value) ? strlen($value) : 0; + if (($strlen > 1 && is_string($value) && ((strpos($value, '[') === 0 && strrpos($value, ']') === $strlen - 1) || (strpos($value, '{') === 0 && strrpos($value, '}') === $strlen - 1) || (strpos($value, '"') === 0 && strrpos($value, '"') === $strlen - 1))) || is_numeric($value)) { $tmp = json_decode($value, $asArray);