Bugzilla – Attachment 143795 Details for
Bug 24606
Allow storing item values as a template for creating new items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24606: Fix encoding issues on decoded content
Bug-24606-Fix-encoding-issues-on-decoded-content.patch (text/plain), 1.69 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-11-11 18:43:41 UTC
(
hide
)
Description:
Bug 24606: Fix encoding issues on decoded content
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-11-11 18:43:41 UTC
Size:
1.69 KB
patch
obsolete
>From 8bc4409773b3f955ab3dac80689eeea0bccddc2b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 11 Nov 2022 15:26:39 -0300 >Subject: [PATCH] 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> >--- > Koha/Item/Template.pm | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > >diff --git a/Koha/Item/Template.pm b/Koha/Item/Template.pm >index b2e04a57d23..d6d0555a9ec 100644 >--- a/Koha/Item/Template.pm >+++ b/Koha/Item/Template.pm >@@ -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 > >-- >2.38.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24606
:
141613
|
141614
|
141615
|
141616
|
141617
|
141717
|
141718
|
141719
|
141720
|
141721
|
141972
|
142003
|
142004
|
142005
|
142006
|
142007
|
142008
|
142833
|
142834
|
142835
|
142836
|
142837
|
142877
|
142878
|
142879
|
142880
|
142881
|
142882
|
142883
|
142884
|
142885
|
142886
|
142887
|
142888
|
143020
|
143569
|
143570
|
143571
|
143572
|
143573
|
143574
|
143575
|
143576
|
143577
|
143578
|
143579
|
143580
|
143581
|
143794
| 143795 |
143796
|
143989
|
143990
|
144161