Merge pull request #6198 from nextcloud/stable11-check-encoding-log
[stable11] Ensure log message is UTF-8 encoded
This commit is contained in:
commit
9a26a3e8d7
|
@ -114,7 +114,18 @@ class File {
|
|||
'user',
|
||||
'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');
|
||||
@chmod(self::$logFile, 0640);
|
||||
if ($handle) {
|
||||
|
|
Loading…
Reference in New Issue