Bugzilla – Attachment 29732 Details for
Bug 12581
/svc/bib endpoint has encoding issues when updating a record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12581 - Fix encoding issues in /svc/bib endpoint
Bug-12581---Fix-encoding-issues-in-svcbib-endpoint.patch (text/plain), 2.20 KB, created by
Petter Goksøyr Åsen
on 2014-07-16 08:01:16 UTC
(
hide
)
Description:
Bug 12581 - Fix encoding issues in /svc/bib endpoint
Filename:
MIME Type:
Creator:
Petter Goksøyr Åsen
Created:
2014-07-16 08:01:16 UTC
Size:
2.20 KB
patch
obsolete
>From bab05ebda3badfd59495995fb4683fd946ff3a5e Mon Sep 17 00:00:00 2001 >From: Petter Goksoyr Asen <boutrosboutrosboutros@gmail.com> >Date: Wed, 16 Jul 2014 09:52:50 +0200 >Subject: [PATCH] Bug 12581 - Fix encoding issues in /svc/bib endpoint >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Updating a record by sending a POST request with the MARCXML data Koha's >/svc/bib endpoint can result in mangled characters in the saved record. >By contrast, the /svc/new_bib endpoint, for creating a new record, >correctly fixes theese encoding issues. > >This patch replicates the fix from svc/new_bib to svc/bib. > >Test plan >* Update a record by sending MARCXML to the /svc/bib endpoint. > The record should contain non-latin characters, for example æ,ø, å. >* Observe that the returned response, and the record in the database > has mangled characters. >* Apply the patch >* Repeat the first step >* Observe that the record now is free from encoding errors. >--- > svc/bib | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > >diff --git a/svc/bib b/svc/bib >index 8f6a168..5b2e273 100755 >--- a/svc/bib >+++ b/svc/bib >@@ -27,6 +27,7 @@ use C4::Auth qw/check_api_auth/; > use C4::Biblio; > use C4::Items; > use XML::Simple; >+use C4::Charset; > > my $query = new CGI; > binmode STDOUT, ':encoding(UTF-8)'; >@@ -82,12 +83,19 @@ sub update_bib { > my $inxml = $query->param('POSTDATA'); > print $query->header(-type => 'text/xml'); > >- my $record = eval {MARC::Record::new_from_xml( $inxml, "utf8", C4::Context->preference('marcflavour'))}; >+ my $marcflavour = C4::Context->preference('marcflavour'); >+ my $record = eval {MARC::Record::new_from_xml( $inxml, "utf8", $marcflavour)}; > my $do_not_escape = 0; > if ($@) { > $result->{'status'} = "failed"; > $result->{'error'} = $@; > } else { >+ # fix character set >+ if ($record->encoding() eq 'MARC-8') { >+ my ($guessed_charset, $charset_errors); >+ ($record, $guessed_charset, $charset_errors) = MarcToUTF8Record($record, $marcflavour); >+ } >+ > my $fullrecord = $record->clone(); > my ( $itemtag, $itemsubfield ) = > GetMarcFromKohaField( "items.itemnumber", '' ); >-- >1.8.3.2
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 12581
:
29732
|
30612