Koha-clms/Koha/REST/V1
Tomas Cohen Arazi 5c89018abd 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>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit cf44929d1c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit cec90fb3c2)
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
(cherry picked from commit f146bf38b1)
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
(cherry picked from commit f146bf38b1)
2021-09-07 04:08:58 +00:00
..
Acquisitions Bug 23858: (follow-up) Return code fix 2019-10-28 12:36:46 +00:00
Clubs Bug 23843: Add mapping to Koha::Club::Holds 2019-10-23 18:03:03 +01:00
Patrons Bug 23805: Update 'Pay' to 'PAYMENT' for consistency 2019-10-24 17:35:20 +01:00
Auth.pm Bug 26322: [19.11.x] Permissions not checked correctly for plugins 2020-09-22 10:15:23 +12:00
Biblios.pm Bug 28604: Prevent double encoding of MARC::Record::MiJ->to_mij output 2021-09-07 04:08:58 +00:00
Checkouts.pm Bug 23843: Add mapping to Koha::Checkout 2019-10-23 18:02:59 +01:00
Cities.pm Bug 23893: Use in /cities 2020-01-18 15:59:49 +00:00
Holds.pm Bug 27179: Misspelling of Method in REST API files 2021-02-08 21:58:31 +01:00
Illrequests.pm Bug 21460: (follow-up) Fix bugs found in QA 2019-04-25 10:46:56 +00:00
Items.pm Bug 23667: Add route to GET /items 2019-10-29 12:20:35 +00:00
Library.pm Bug 23843: Add mapping to Koha::Library 2019-10-23 18:03:11 +01:00
OAuth.pm Bug 23146: Add support for Basic auth on the OAuth2 token endpoint 2019-06-24 16:05:31 +01:00
Patrons.pm Bug 23634: (QA follow-up) Our PUT is really a PATCH 2020-08-25 15:36:33 +12:00
ReturnClaims.pm Bug 28586: (follow-up) updated_by should be set 2021-07-12 01:10:35 +00:00
Stage.pm Revert "Bug 22026: Removed 'use Modern::Perl;' from Koha::REST::classes" 2019-02-26 11:04:08 -05:00
Static.pm Bug 27179: Misspelling of Method in REST API files 2021-02-08 21:58:31 +01:00