diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-08-21 10:20:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-21 10:20:52 +0200 |
commit | 223265b36934af467556b1f31f7f63b87bd30b51 (patch) | |
tree | 2f2b3de16ae6f491550ad7e068af3ba1bc9387ec /lib | |
parent | 2404c854c47de2a7a5c02bfe55a8b1197dd52266 (diff) | |
parent | c016b01bf91e201d58d7196c24cab4a95b66f219 (diff) | |
download | nextcloud-server-223265b36934af467556b1f31f7f63b87bd30b51.tar.gz nextcloud-server-223265b36934af467556b1f31f7f63b87bd30b51.zip |
Merge pull request #6169 from nextcloud/check-encoding-log
Ensure log message is UTF-8 encoded
Diffstat (limited to 'lib')
-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); |