-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Closed
Copy link
Description
Symfony version(s) affected
4.4 - current
Description
The AbstractSurrogateFragmentRenderer
throws an exception if non-scalar values are passed as attributes, but the detection has an early returns in case an attribute's $value
is an array:
symfony/src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php
Lines 96 to 107 in f0ffa47
private function containsNonScalars(array $values): bool | |
{ | |
foreach ($values as $value) { | |
if (\is_array($value)) { | |
return $this->containsNonScalars($value); | |
} elseif (!is_scalar($value) && null !== $value) { | |
return true; | |
} | |
} | |
return false; | |
} |
How to reproduce
Pass on attributes in the form [[], <non-scalar>]
, containsNonScalars
will return false
instead of true
.
Possible Solution
Something like this:
private function containsNonScalars(array $values): bool
{
foreach ($values as $value) {
if (\is_array($value) && $this->containsNonScalars($value)) {
return true;
}
if (!is_scalar($value) && null !== $value) {
return true;
}
}
}
Additional Context
No response