Bug 23173: (follow-up) Allow for wide characters
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Thu, 6 Feb 2020 11:08:41 +0000 (11:08 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 6 Apr 2020 10:04:45 +0000 (11:04 +0100)
The conversion of the metadata into Base64 for passing in the API call
to the plugin API routes was failing if the metadata contained a wide
character, so we now encode it into UTF-8 first

Signed-off-by: Niamh Walker-Headon <Niamh.Walker-Headon@tudublin.ie>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Illrequest/Availability.pm

index 099f885..a9ca6ef 100644 (file)
@@ -21,7 +21,8 @@ use Modern::Perl;
 
 use JSON;
 use MIME::Base64 qw( encode_base64 );
-use URI::Escape qw ( uri_escape );
+use URI::Escape qw( uri_escape );
+use Encode qw( encode );
 
 use Koha::Plugins;
 
@@ -114,7 +115,7 @@ sub prep_metadata {
     # so this function returns something predictable that we can test!
     my $json = JSON->new;
     $json->canonical([1]);
-    return uri_escape(encode_base64($json->encode($metadata)));
+    return uri_escape(encode_base64(encode('utf-8',$json->encode($metadata))));
 }
 
 =head1 AUTHOR