mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-02 19:27:37 +02:00
Avoid sending unicode chars in headers for Wildfire/FirePHPHandler/ChromePHPHandler, fixes #1521
This commit is contained in:
@@ -36,6 +36,17 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
Logger::EMERGENCY => 'ERROR',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
|
||||
*/
|
||||
public function __construct(?string $dateFormat = null)
|
||||
{
|
||||
parent::__construct($dateFormat);
|
||||
|
||||
// http headers do not like non-ISO-8559-1 characters
|
||||
$this->removeJsonEncodeOption(JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -145,7 +145,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
self::$json['request_uri'] = $_SERVER['REQUEST_URI'] ?? '';
|
||||
}
|
||||
|
||||
$json = Utils::jsonEncode(self::$json, null, true);
|
||||
$json = Utils::jsonEncode(self::$json, Utils::DEFAULT_JSON_FLAGS & ~JSON_UNESCAPED_UNICODE, true);
|
||||
$data = base64_encode(utf8_encode($json));
|
||||
if (strlen($data) > 3 * 1024) {
|
||||
self::$overflowed = true;
|
||||
|
@@ -63,7 +63,7 @@ final class Utils
|
||||
* Return the JSON representation of a value
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param int $encodeFlags flags to pass to json encode, defaults to JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
|
||||
* @param int $encodeFlags flags to pass to json encode, defaults to DEFAULT_JSON_FLAGS
|
||||
* @param bool $ignoreErrors whether to ignore encoding errors or to throw on error, when ignored and the encoding fails, "null" is returned which is valid json for null
|
||||
* @throws \RuntimeException if encoding fails and errors are not ignored
|
||||
* @return string when errors are ignored and the encoding fails, "null" is returned which is valid json for null
|
||||
|
Reference in New Issue
Block a user