From: Marcin Haba Date: Thu, 21 Jan 2021 05:21:36 +0000 (+0100) Subject: baculum: Fix #2560 in restore wizard display names encoded in non-UTF encoding X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45e42a653da83f086a2eca54f83b702dc64a4563;p=thirdparty%2Fbacula.git baculum: Fix #2560 in restore wizard display names encoded in non-UTF encoding --- diff --git a/gui/baculum/protected/API/Class/BaculumAPIServer.php b/gui/baculum/protected/API/Class/BaculumAPIServer.php index 568c2a1dd..0caf54830 100644 --- a/gui/baculum/protected/API/Class/BaculumAPIServer.php +++ b/gui/baculum/protected/API/Class/BaculumAPIServer.php @@ -236,7 +236,13 @@ abstract class BaculumAPIServer extends TPage { private function getOutput() { $output = array('output' => $this->output, 'error' => $this->error); $this->setOutputHeaders(); - $json = json_encode($output); + $json = ''; + if (PHP_VERSION_ID >= 70200) { + // Allow displaying characters encoded in non-UTF encoding (supported from PHP 7.2.0) + $json = json_encode($output, JSON_INVALID_UTF8_SUBSTITUTE); + } else { + $json = json_encode($output); + } return $json; }