]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix UTF-8 encoding before JSON export
authorEric Fredj <efredj@octo.com>
Tue, 5 Apr 2016 14:30:08 +0000 (16:30 +0200)
committerEric Fredj <efredj@octo.com>
Tue, 5 Apr 2016 18:03:57 +0000 (20:03 +0200)
inc/poche/Poche.class.php
inc/poche/Tools.class.php

index 400857b492c46b3f307fe77be2d6fefb39131ae4..1476d158a268e9f5aeb8c407903e75ef61055fb6 100755 (executable)
@@ -908,7 +908,7 @@ class Poche
         $entries = $this->store->retrieveAllWithTags($this->user->getId());
         if ($entries) {
             echo $this->tpl->render('export.twig', array(
-            'export' => Tools::renderJson($entries),
+            'export' => Tools::renderJson(Tools::utf8ize($entries)),
             ));
             Tools::logm('export view');
         } else {
index e5e150cdb7d8f3bce3c7633c675a1d403215858a..d84850cf739e36f9631d30ec99967f9e666cc81b 100755 (executable)
@@ -232,6 +232,27 @@ final class Tools
         exit();
     }
 
+    /**
+     * UTF-8 encode array of string
+     *
+     * @param $data
+     */
+    public static function utf8ize($data) 
+    {
+       if (is_array($data)) 
+        {
+            foreach ($data as $k => $v) 
+            {
+                $data[$k] = self::utf8ize($v);
+            }
+        }
+        else if (is_string ($data)) 
+        {
+            return utf8_encode($data);
+        }
+        return $data;
+    }
+
     /**
      * Create new line in log file
      *