mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-03 19:57:41 +02:00
Fix gelf formatter keys to strip invalid characters, fixes #1927
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Monolog;
|
|||||||
|
|
||||||
class_alias(JsonSerializableDateTimeImmutable::class, 'Monolog\DateTimeImmutable');
|
class_alias(JsonSerializableDateTimeImmutable::class, 'Monolog\DateTimeImmutable');
|
||||||
|
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
if (false) {
|
if (false) {
|
||||||
/**
|
/**
|
||||||
* @deprecated Use \Monolog\JsonSerializableDateTimeImmutable instead.
|
* @deprecated Use \Monolog\JsonSerializableDateTimeImmutable instead.
|
||||||
|
@@ -115,6 +115,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($extra as $key => $val) {
|
foreach ($extra as $key => $val) {
|
||||||
|
$key = (string) preg_replace('#[^\w\.\-]#', '-', $key);
|
||||||
$val = \is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
$val = \is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
||||||
$len = \strlen($this->extraPrefix . $key . $val);
|
$len = \strlen($this->extraPrefix . $key . $val);
|
||||||
if ($len > $this->maxLength) {
|
if ($len > $this->maxLength) {
|
||||||
@@ -126,6 +127,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($context as $key => $val) {
|
foreach ($context as $key => $val) {
|
||||||
|
$key = (string) preg_replace('#[^\w\.\-]#', '-', $key);
|
||||||
$val = \is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
$val = \is_scalar($val) || null === $val ? $val : $this->toJson($val);
|
||||||
$len = \strlen($this->contextPrefix . $key . $val);
|
$len = \strlen($this->contextPrefix . $key . $val);
|
||||||
if ($len > $this->maxLength) {
|
if ($len > $this->maxLength) {
|
||||||
|
Reference in New Issue
Block a user