Koha-clms/Koha/REST/V1
Tomas Cohen Arazi 7a908117dc 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>
2021-06-23 15:09:56 +02:00
..
Acquisitions Bug 20212: Filter on publisher and notes 2021-01-28 16:44:48 +01:00
CashRegisters Bug 26274: Add cashups api routes 2021-02-12 12:33:41 +01:00
Clubs Bug 27593: Consistent behavior for club holds route 2021-02-23 13:16:07 +01:00
Config/SMTP Bug 22343: API routes for SMTP servers CRUD 2020-10-02 10:54:40 +02:00
Patrons Bug 28424: Fix patron credits route (POST) 2021-05-25 09:28:17 +02:00
AdvancedEditorMacro.pm Bug 25502: Adapt Advanced macros routes to current guidelines 2020-05-19 15:21:16 +01:00
Auth.pm Bug 27760: Make authenticate_api_request call stash_overrides 2021-05-04 14:22:02 +02:00
Biblios.pm Bug 28604: Prevent double encoding of MARC::Record::MiJ->to_mij output 2021-06-23 15:09:56 +02:00
Checkouts.pm Bug 27544: Simplify GET /checkouts implementation 2021-01-28 16:41:20 +01:00
CirculationRules.pm Bug 18936: (QA follow-up) Add missing POD 2020-02-04 09:56:30 +00:00
Cities.pm Bug 25048: Make successful resource deletion return 204 2020-04-29 16:24:43 +01:00
Holds.pm Bug 28369: Set additionalProperties: false and fix things 2021-05-25 09:28:18 +02:00
Illbackends.pm Bug 22615: Fix perlcritic 2020-03-05 13:03:46 +00:00
Illrequests.pm Bug 23391: Remove warnings 2020-07-20 17:45:30 +02:00
ImportBatchProfiles.pm Bug 23019: (follow-up) Fix other things 2020-11-11 15:55:49 +01:00
Items.pm Bug 27931: Add GET /items/:item_id/pickup_locations 2021-06-14 17:35:19 +02:00
Libraries.pm Bug 25032: Make existing controllers use unhandled_exception 2020-04-29 16:24:18 +01:00
OAuth.pm Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
Patrons.pm Bug 28002: Add extended_attributes support to POST /patrons 2021-04-22 14:50:12 +02:00
Quotes.pm Bug 27251: Rewrite QOTD with the Koha REST API 2021-01-29 09:03:45 +01:00
ReturnClaims.pm Bug 28271: Add the ability to set a new lost status when a claim is resolved 2021-06-21 10:50:09 +02:00
Stage.pm Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
Static.pm Bug 27179: Misspelling of Method in REST API files 2021-01-22 14:59:27 +01:00
TransferLimits.pm Bug 26633: (QA follow-up) Tests on error condition 2021-03-16 16:08:30 +01:00