Bugzilla – Attachment 122293 Details for
Bug 28604
Bad encoding when using marc-in-json
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28604: Prevent double encoding of MARC::Record::MiJ->to_mij output
Bug-28604-Prevent-double-encoding-of-MARCRecordMiJ.patch (text/plain), 2.72 KB, created by
Martin Renvoize (ashimema)
on 2021-06-22 15:34:25 UTC
(
hide
)
Description:
Bug 28604: Prevent double encoding of MARC::Record::MiJ->to_mij output
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-06-22 15:34:25 UTC
Size:
2.72 KB
patch
obsolete
>From da53e6c71b95cea6d2d825a2071c3c21199cacbb Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 18 Jun 2021 18:32:37 -0300 >Subject: [PATCH] Bug 28604: Prevent double encoding of > MARC::Record::MiJ->to_mij output > >This patch fixes a double-encoding issue with MiJ output. > >Mojolicious' *text* renderer encodes the passed information according to >the request context. [1] > >MARC::Record::MiJ->to_mij, conveniently encodes the string before >output [2]. > >This causes double encoding. > >So the solution to this situation, is to use the *data* renderer, which >doesn't perform any encoding [3]. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/biblios.t >=> FAIL: Tests contain diacritics and fail! >3. Have a record with diacritics >4. Try the API routes for fetching a biblio: > $ curl --location --request GET 'http://localhost:8080/api/v1/public/biblios/144' \ > --header 'Accept: application/marc-in-json' > (replace the record id with the one you've chosen) >=> FAIL: Boo, double encoding >5. Bonus point: you can try it on the non-public route, but you need > more configuration boilerplate (basic auth, permissions). If you look > at the fix, you will understand the tests cover it and no need to > complicate yourself. >6. Apply this patch >7. Repeat 2 >=> SUCCESS: Tests pass! >8. Repeat 4 (and maybe 5) >=> SUCCESS: No double encoding! Yay! >9. Sign off :-D > >[1] https://metacpan.org/release/MRAMBERG/Convos-0.5/view/local/lib/perl5/Mojolicious/Guides/Rendering.pod#Rendering-text >[2] https://metacpan.org/dist/MARC-File-MiJ/source/lib/MARC/Record/MiJ.pm#L111 >[3] https://metacpan.org/release/MRAMBERG/Convos-0.5/view/local/lib/perl5/Mojolicious/Guides/Rendering.pod#Rendering-data > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/REST/V1/Biblios.pm | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index aa44f30e64..92d31348d4 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -76,7 +76,7 @@ sub get { > mij => { > status => 200, > format => 'mij', >- text => $record->to_mij >+ data => $record->to_mij > }, > marc => { > status => 200, >@@ -207,7 +207,7 @@ sub get_public { > mij => { > status => 200, > format => 'mij', >- text => $record->to_mij >+ data => $record->to_mij > }, > marc => { > status => 200, >-- >2.20.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 28604
:
122188
|
122189
|
122190
|
122191
|
122292
| 122293