Skip to content

Commit 5193780

Browse files
authored
Merge pull request #2081 from nowackipawel/patch-71
JSON format checking improved
2 parents cd97aba + 6f30293 commit 5193780

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

system/Entity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ private function castAsJson($value, bool $asArray = false)
588588
$tmp = ! is_null($value) ? ($asArray ? [] : new \stdClass) : null;
589589
if (function_exists('json_decode'))
590590
{
591-
if ((is_string($value) && (strpos($value, '[') === 0 || strpos($value, '{') === 0 || (strpos($value, '"') === 0 && strrpos($value, '"') === 0 ))) || is_numeric($value))
591+
if ((is_string($value) && strlen($value) > 1 && in_array($value{0}, ['[','{','"'])) || is_numeric($value))
592592
{
593593
$tmp = json_decode($value, $asArray);
594594

0 commit comments

Comments
 (0)