Bug 32336: Fix encoding of MARCXML output for REST API (UNIMARC)

Test plan:
1. Be sure to test on a UNIMARC instance
2. Enable system preferences RESTPublicAPI and RESTPublicAnonymousRequests
3. Create a biblio with some diacritics
4. Restart koha and do not interact with OPAC or the staff interface
   (this may change $MARC::File::XML::RecordFormat)
5. Query the public API to retrieve the created biblio in MARCXML. For
   instance with cURL:

   curl -H 'Accept: application/marcxml+xml' \
    http://koha.local/api/v1/public/biblios/<biblionumber>

   You should see encoding issues.
6. Apply the patch and restart Koha.
7. Repeat step 5.
   You should see no encoding issues.
8. You should also test /api/v1/biblios/<biblionumber> (this one
   requires authentication, so cURL might not be the most practical
   tool; use your favorite tool for this)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Julian Maurice 2022-11-23 15:43:06 +01:00 committed by Tomas Cohen Arazi
parent 8bfb09b68b
commit 1a02ba56f1
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -68,12 +68,13 @@ sub get {
}
else {
my $record = $biblio->metadata->record;
my $marcflavour = C4::Context->preference("marcflavour");
$c->respond_to(
marcxml => {
status => 200,
format => 'marcxml',
text => $record->as_xml_record
text => $record->as_xml_record($marcflavour),
},
mij => {
status => 200,
@ -204,7 +205,7 @@ sub get_public {
marcxml => {
status => 200,
format => 'marcxml',
text => $record->as_xml_record
text => $record->as_xml_record($marcflavour),
},
mij => {
status => 200,