Bug 12114: Fix encoding problem with reports JSON web service (opac)
authorKatrin Fischer <Katrin.Fischer.83@web.de>
Sun, 20 Apr 2014 22:01:19 +0000 (00:01 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 25 Apr 2014 15:31:33 +0000 (15:31 +0000)
- catalog a record that includes umlauts äöü
- write a report, that has the record in the result set
- access the JSON output of the report
  <OPAC BaseURL/cgi-bin/koha/svc/report?id=1
- verify the umlaut displays not correctly
- switch the encoding in the browser to 'western'/latin1
- verify the umlaut now displays correctly
- apply patch
- verify umlaut now displays correctly from the beginning

Based on paste from Galen Charlton.

Followed test plan. Result as expected.
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

opac/svc/report

index 1ded9c9..0b17a4d 100755 (executable)
@@ -24,7 +24,7 @@
 use Modern::Perl;
 
 use C4::Reports::Guided;
-use JSON;
+use JSON::XS;
 use CGI;
 
 use Koha::Cache;
@@ -70,7 +70,7 @@ unless ($json_text) {
         else {
             $lines = $sth->fetchall_arrayref;
         }
-        $json_text = to_json($lines);
+        $json_text = encode_json($lines);
 
         if ($cache_active) {
             $cache->set_in_cache( $cache_key, $json_text,
@@ -78,7 +78,7 @@ unless ($json_text) {
         }
     }
     else {
-        $json_text = to_json($errors);
+        $json_text = encode_json($errors);
     }
 }