From ec3e0e3f907d25456063ec1e1799eb0bcf4a5bab Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 13 Nov 2019 10:47:25 +0100 Subject: [PATCH] set json flags correctly for SlackRecord, fixes #1396, closes #1397 --- src/Monolog/Handler/Slack/SlackRecord.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Handler/Slack/SlackRecord.php b/src/Monolog/Handler/Slack/SlackRecord.php index 2a8818d4f..39455501f 100644 --- a/src/Monolog/Handler/Slack/SlackRecord.php +++ b/src/Monolog/Handler/Slack/SlackRecord.php @@ -208,13 +208,17 @@ public function stringify($fields) { $normalized = $this->normalizerFormatter->format($fields); $prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128; + $flags = 0; + if (PHP_VERSION_ID >= 50400) { + $flags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; + } $hasSecondDimension = count(array_filter($normalized, 'is_array')); $hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric')); return $hasSecondDimension || $hasNonNumericKeys - ? Utils::jsonEncode($normalized, $prettyPrintFlag) - : Utils::jsonEncode($normalized); + ? Utils::jsonEncode($normalized, $prettyPrintFlag | $flags) + : Utils::jsonEncode($normalized, $flags); } /**