diff options
author | Eric Fredj <efredj@octo.com> | 2016-04-05 16:30:08 +0200 |
---|---|---|
committer | Eric Fredj <efredj@octo.com> | 2016-04-05 20:03:57 +0200 |
commit | 206c2a734e2a0d100af6d772d90b01c5cb8fe870 (patch) | |
tree | b39f4a6e357b68e3b2f999ab9560941005150450 /inc | |
parent | 04ffc7fb11f9e98991ee5bc0511ce5d96a7755c7 (diff) | |
download | wallabag-206c2a734e2a0d100af6d772d90b01c5cb8fe870.tar.gz wallabag-206c2a734e2a0d100af6d772d90b01c5cb8fe870.tar.zst wallabag-206c2a734e2a0d100af6d772d90b01c5cb8fe870.zip |
Fix UTF-8 encoding before JSON export
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/poche/Poche.class.php | 2 | ||||
-rwxr-xr-x | inc/poche/Tools.class.php | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 400857b4..1476d158 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -908,7 +908,7 @@ class Poche | |||
908 | $entries = $this->store->retrieveAllWithTags($this->user->getId()); | 908 | $entries = $this->store->retrieveAllWithTags($this->user->getId()); |
909 | if ($entries) { | 909 | if ($entries) { |
910 | echo $this->tpl->render('export.twig', array( | 910 | echo $this->tpl->render('export.twig', array( |
911 | 'export' => Tools::renderJson($entries), | 911 | 'export' => Tools::renderJson(Tools::utf8ize($entries)), |
912 | )); | 912 | )); |
913 | Tools::logm('export view'); | 913 | Tools::logm('export view'); |
914 | } else { | 914 | } else { |
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index e5e150cd..d84850cf 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php | |||
@@ -233,6 +233,27 @@ final class Tools | |||
233 | } | 233 | } |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * UTF-8 encode array of string | ||
237 | * | ||
238 | * @param $data | ||
239 | */ | ||
240 | public static function utf8ize($data) | ||
241 | { | ||
242 | if (is_array($data)) | ||
243 | { | ||
244 | foreach ($data as $k => $v) | ||
245 | { | ||
246 | $data[$k] = self::utf8ize($v); | ||
247 | } | ||
248 | } | ||
249 | else if (is_string ($data)) | ||
250 | { | ||
251 | return utf8_encode($data); | ||
252 | } | ||
253 | return $data; | ||
254 | } | ||
255 | |||
256 | /** | ||
236 | * Create new line in log file | 257 | * Create new line in log file |
237 | * | 258 | * |
238 | * @param $message | 259 | * @param $message |