mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-23 01:26:11 +02:00
Introduce a depth parameter for normalization to limit stack nesting
This commit is contained in:
@@ -55,8 +55,12 @@ class NormalizerFormatter implements FormatterInterface
|
||||
return $records;
|
||||
}
|
||||
|
||||
protected function normalize($data)
|
||||
protected function normalize($data, $depth = 0)
|
||||
{
|
||||
if ($depth > 9) {
|
||||
return 'Over 9 levels deep, aborting normalization';
|
||||
}
|
||||
|
||||
if (null === $data || is_scalar($data)) {
|
||||
if (is_float($data)) {
|
||||
if (is_infinite($data)) {
|
||||
@@ -79,7 +83,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
$normalized['...'] = 'Over 1000 items, aborting normalization';
|
||||
break;
|
||||
}
|
||||
$normalized[$key] = $this->normalize($value);
|
||||
$normalized[$key] = $this->normalize($value, $depth+1);
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
|
Reference in New Issue
Block a user