diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Log/File.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php index 97ec5012b1f..c6677dd528d 100644 --- a/lib/private/Log/File.php +++ b/lib/private/Log/File.php @@ -117,7 +117,18 @@ class File { 'userAgent', 'version' ); - $entry = json_encode($entry); + // PHP's json_encode only accept proper UTF-8 strings, loop over all + // elements to ensure that they are properly UTF-8 compliant or convert + // them manually. + foreach($entry as $key => $value) { + if(is_string($value)) { + $testEncode = json_encode($value); + if($testEncode === false) { + $entry[$key] = utf8_encode($value); + } + } + } + $entry = json_encode($entry, JSON_PARTIAL_OUTPUT_ON_ERROR); $handle = @fopen(self::$logFile, 'a'); if ((fileperms(self::$logFile) & 0777) != 0640) { @chmod(self::$logFile, 0640); |