[Bug 28604] New: bad encoding when using marc-in-json
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Bug ID: 28604 Summary: bad encoding when using marc-in-json Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: lucas@bywatersolutions.com There are some UTF-8 encoding problems when using marc-in-json that have diacritics in them, I encountered this when using the '/api/v1/public/biblios/' API route. To recreate: -Add some diacritics to a MARC field, I am using the 538$a and added the note 'Tést nöte'. -Look at the what the API returns, I used this: curl --location --request GET 'http://localhost:8080/api/v1/public/biblios/144' \ --header 'Accept: application/marc-in-json' The 538$a note comes out looking like this: Tést nöte -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Status|NEW |Needs Signoff CC| |tomascohen@gmail.com -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 122188 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122188&action=edit Bug 28604: Regression tests This patch introduces regression tests for the encoding issue with MiJ output. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 122189 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122189&action=edit 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/Mojoli... [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/Mojoli... Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|bad encoding when using |Bad encoding when using |marc-in-json |marc-in-json -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #3 from Lucas Gass <lucas@bywatersolutions.com> --- Created attachment 122190 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122190&action=edit Bug 28604: Regression tests This patch introduces regression tests for the encoding issue with MiJ output. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #122189|0 |1 is obsolete| | --- Comment #4 from Lucas Gass <lucas@bywatersolutions.com> --- Created attachment 122191 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122191&action=edit 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/Mojoli... [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/Mojoli... Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #122188|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #122190|0 |1 is obsolete| | --- Comment #5 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 122292 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122292&action=edit Bug 28604: Regression tests This patch introduces regression tests for the encoding issue with MiJ output. 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #122191|0 |1 is obsolete| | --- Comment #6 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 122293 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122293&action=edit 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/Mojoli... [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/Mojoli... 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> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA CC| |martin.renvoize@ptfs-europe | |.com --- Comment #7 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- All works well, QA script is happy, Tests pass. Passing QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |21.11.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #8 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Pushed to master for 21.11, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|21.11.00 |21.11.00,21.05.02 released in| | CC| |kyle@bywatersolutions.com Status|Pushed to master |Pushed to stable --- Comment #9 from Kyle M Hall <kyle@bywatersolutions.com> --- Pushed to 21.05.x for 21.05.02 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|21.11.00,21.05.02 |21.11.00,21.05.02,20.11.09 released in| | Status|Pushed to stable |Pushed to oldstable CC| |fridolin.somers@biblibre.co | |m --- Comment #10 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to 20.11.x for 20.11.09 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED CC| |victor@tuxayo.net Status|Pushed to oldstable |RESOLVED --- Comment #11 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #12 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Victor Grousset/tuxayo from comment #11)
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.
Can you please backport it to the 20.05.x branch? Thanks :-) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |--- Status|RESOLVED |REOPENED Version(s)|21.11.00,21.05.02,20.11.09 |21.11.00,21.05.02,20.11.09, released in| |20.05.15 --- Comment #13 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Backported: Pushed to 20.05.x branch for 20.05.15 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to oldoldstable --- Comment #14 from Victor Grousset/tuxayo <victor@tuxayo.net> --- (sorry the spam, I couldn't find a quiet way to go from "closed" to "pushed to oldoldstable") -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 wainuiwitikapark@catalyst.net.nz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wainuiwitikapark@catalyst.n | |et.nz --- Comment #15 from wainuiwitikapark@catalyst.net.nz --- Should this be backported to 19.11.x for 19.11.21? Or if it contains string changes, backported to 19.11.22? As we are currently in a string freeze. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #16 from wainuiwitikapark@catalyst.net.nz --- Should this be backported to 19.11.x for 19.11.22? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #17 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to wainuiwitikapark from comment #16)
Should this be backported to 19.11.x for 19.11.22?
If it applies, backport it. It has no string changes -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 wainuiwitikapark@catalyst.net.nz changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to oldoldstable |Pushed to oldoldoldstable Version(s)|21.11.00,21.05.02,20.11.09, |21.11.00,21.05.02,20.11.09, released in|20.05.15 |20.05.15,19.11.22 --- Comment #18 from wainuiwitikapark@catalyst.net.nz --- Backported to 19.11.x for 19.11.22 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #19 from wainuiwitikapark@catalyst.net.nz --- On 19.11.x Test Result (2 failures / ±0) t_db_dependent_api_v1_biblios_t.get() tests (703) t_db_dependent_api_v1_biblios_t.get_public() tests (703) I am getting these failtures Can someone please write a patch for that -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #20 from Victor Grousset/tuxayo <victor@tuxayo.net> --- I think it's okay to just revert it. The severity is only "normal" and it was requested for 20.05.x I read comment 17 as an advice about the string freeze and not as a need for 19.11 Could be wrong though. If it turns out to be needed and is fixed for 19.11 , then it could still be backported next month. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 --- Comment #21 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to wainuiwitikapark from comment #19)
On 19.11.x
Test Result (2 failures / ±0)
t_db_dependent_api_v1_biblios_t.get() tests (703) t_db_dependent_api_v1_biblios_t.get_public() tests (703)
I am getting these failtures
Can someone please write a patch for that
I tried to understand what's going on yesterday, and couldn't figure why it is failing, I agree with Victor, that this can safely be reverted to keep jenkins happy, and if someone requests it, we can come back to it. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28604 wainuiwitikapark@catalyst.net.nz changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|21.11.00,21.05.02,20.11.09, |21.11.00,21.05.02,20.11.09, released in|20.05.15,19.11.22 |20.05.15 Resolution|--- |FIXED Status|Pushed to oldoldoldstable |RESOLVED --- Comment #22 from wainuiwitikapark@catalyst.net.nz --- Ok so reverted these patches - so not backported to 19.11.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org