1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Related to Issue #3741 - Incorrect encoding of a plugin language file could cause json encoding to fail.

This commit is contained in:
Cameron
2020-03-24 13:57:05 -07:00
parent 6c242729b9
commit 852ab5a32f
4 changed files with 64 additions and 10 deletions

View File

@@ -572,7 +572,16 @@ class e_array {
if($mode === 'json')
{
return json_encode($ArrayData, JSON_PRETTY_PRINT);
//todo discuss - move to e_parse::toJSON() ?
$encoded = json_encode($ArrayData, JSON_PRETTY_PRINT);
if(json_last_error() === JSON_ERROR_UTF8)
{
$ArrayData = e107::getParser()->toUTF8($ArrayData);
$encoded = json_encode($ArrayData, JSON_PRETTY_PRINT);
//todo log
}
return $encoded;
}
$Array = var_export($ArrayData, true);
@@ -586,6 +595,8 @@ class e_array {
}
/**
* @DEPRECATED - Backwards Compatible. Use e107::serialize() instead;
* @param array $ArrayData array to be stored
@@ -628,7 +639,7 @@ class e_array {
*
* @param string $systemLocationFile relative to e_SYSTEM file path (without the extension)
* @param string $extension [optional] file extension, default is 'php'
* @return array or false when file not found (or on error)
* @return array|false false when file not found (or on error)
*/
public function load($systemLocationFile, $extension = 'php')
{
@@ -650,7 +661,7 @@ class e_array {
*
* @param string $systemLocationFile relative to e_SYSTEM file path (without the extension)
* @param string $extension [optional] file extension, default is 'php'
* @return array or false when file not found (or on error)
* @return array|false when file not found (or on error)
*/
public function store($array, $systemLocationFile, $extension = 'php')
{