Bug 24606: Fix encoding issues on decoded content
This patch makes the `decoded_contents` method UTF-8 encode the data before calling the relevant decode_json, as expected by the JSON library [1]. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Item/Template.t => FAIL: Tests fail! 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! [1] `Any decoding or encoding (e.g. to UTF-8 or UTF-16) needs to be done yourself, e.g. using the Encode module.` https://metacpan.org/pod/JSON Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
1d65a71cf6
commit
8bc4409773
|
|
@ -17,7 +17,8 @@ package Koha::Item::Template;
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use JSON qw( encode_json decode_json );
|
||||
use Encode qw(encode_utf8);
|
||||
use JSON qw(encode_json decode_json);
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ Koha::Item::Template - Koha Item Template Object class
|
|||
|
||||
=head1 API
|
||||
|
||||
=head2 Class Methods
|
||||
=head2 Class methods
|
||||
|
||||
=head3 store
|
||||
|
||||
|
|
@ -55,10 +56,12 @@ Returns a deserilized perl structure of the JSON formatted contents
|
|||
sub decoded_contents {
|
||||
my ($self) = @_;
|
||||
|
||||
return decode_json( $self->contents ) if $self->contents;
|
||||
return decode_json( encode_utf8($self->contents) ) if $self->contents;
|
||||
}
|
||||
|
||||
=head3 type
|
||||
=head2 Internal methods
|
||||
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue