Fix "malformed UTF-8" error with log viewing.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-01-31 21:43:20 -06:00
parent 7e97caa425
commit 762e0a7c84
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
1 changed files with 6 additions and 1 deletions

View File

@ -28,8 +28,11 @@ trait LogViewerTrait
$log_contents_parts = explode("\n", file_get_contents($log_path));
$log_contents_parts = str_replace(['>', '<'], ['&gt;', '&lt;'], $log_contents_parts);
$log_contents = implode("\n", $log_contents_parts);
$log_contents = mb_convert_encoding($log_contents, 'UTF-8', 'UTF-8');
return $response->withJson([
'contents' => implode("\n", $log_contents_parts),
'contents' => $log_contents,
'eof' => true,
]);
}
@ -66,7 +69,9 @@ trait LogViewerTrait
}
$log_contents_parts = str_replace(['>', '<'], ['&gt;', '&lt;'], $log_contents_parts);
$log_contents = implode("\n", $log_contents_parts);
$log_contents = mb_convert_encoding($log_contents, 'UTF-8', 'UTF-8');
fclose($fp);
}