Bugzilla – Attachment 153014 Details for
Bug 33404
Authorities imported from Z39.50 in encodings other than UTF-8 are corrupted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33404: Z3950SearchAuth: Save in UTF-8 encoding
Bug-33404-Z3950SearchAuth-Save-in-UTF-8-encoding.patch (text/plain), 4.64 KB, created by
Jonathan Druart
on 2023-07-04 12:22:29 UTC
(
hide
)
Description:
Bug 33404: Z3950SearchAuth: Save in UTF-8 encoding
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-07-04 12:22:29 UTC
Size:
4.64 KB
patch
obsolete
>From 819bd0685ceaa9d9cdf9c4ee74827316fb910022 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 24 May 2023 14:57:46 +0000 >Subject: [PATCH] Bug 33404: Z3950SearchAuth: Save in UTF-8 encoding > >Test plan: >[1] If you have access to a Z3950 MARC8 auth server, search > for an authority record and import it. >[2] If you have access to a Z3950 UTF8 auth server, search > for an authority record and import it. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Breeding.pm | 39 ++++++++++++++++++++++----------------- > 1 file changed, 22 insertions(+), 17 deletions(-) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index efc9029f48a..45a0563dcc3 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -478,9 +478,6 @@ sub ImportBreedingAuth { > > my $controlnumber = $marcrecord->field('001')->data; > >- # Normalize the record so it doesn't have separated diacritics >- SetUTF8Flag($marcrecord); >- > $searchbreeding->execute($controlnumber,$heading); > my ($breedingid) = $searchbreeding->fetchrow; > >@@ -578,31 +575,34 @@ sub Z3950SearchAuth { > for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) { > my $rec = $oResult[$k]->record($i); > if ($rec) { >+ my $marcdata = $rec->raw(); > my $marcrecord; >- my $marcdata; >- $marcdata = $rec->raw(); >- >- my ($charset_result, $charset_errors); > if( $servers[$k]->{servertype} eq 'sru' ) { >- $marcrecord = MARC::Record->new_from_xml( $marcdata, 'UTF-8', $servers[$k]->{syntax} ); >- $marcrecord->encoding('UTF-8'); >+ $marcrecord = eval { MARC::Record->new_from_xml( $marcdata, 'UTF-8', $servers[$k]->{syntax} ) }; >+ if( !$marcrecord || $@ ) { >+ _dump_conversion_error( $servers[$k]->{servername}, $marcdata, $@ ); >+ next; # skip this one >+ } > } else { >+ my ($charset_result, $charset_errors); > ( $marcrecord, $charset_result, $charset_errors ) = MarcToUTF8Record( $marcdata, $marc_type, $encoding[$k] ); >+ if( !$marcrecord || @$charset_errors ) { >+ _dump_conversion_error( $servers[$k]->{servername}, $marcdata, $charset_result, $charset_errors ); >+ next; # skip this one >+ } > } >- my $heading; >- my $heading_authtype_code; >- $heading_authtype_code = GuessAuthTypeCode($marcrecord); >- next if ( not defined $heading_authtype_code ) ; >+ $marcrecord->encoding('UTF-8'); >+ SetUTF8Flag($marcrecord); > >- $heading = GetAuthorizedHeading({ record => $marcrecord }); >- >- my $breedingid = ImportBreedingAuth( $marcrecord, $serverhost[$k], $encoding[$k], $heading ); >+ my $heading_authtype_code = GuessAuthTypeCode($marcrecord) or next; >+ my $heading = GetAuthorizedHeading({ record => $marcrecord }); >+ my $breedingid = ImportBreedingAuth( $marcrecord, $serverhost[$k], 'UTF-8', $heading ); > my %row_data; > $row_data{server} = $servers[$k]->{'servername'}; > $row_data{breedingid} = $breedingid; > $row_data{heading} = $heading; > $row_data{authid} = $authid; >- $row_data{heading_code} = $heading_authtype_code; >+ $row_data{heading_code} = $heading_authtype_code; > push( @breeding_loop, \%row_data ); > } > else { >@@ -639,6 +639,11 @@ sub Z3950SearchAuth { > ); > } > >+sub _dump_conversion_error { >+ require Data::Dumper; >+ warn Data::Dumper->new([ 'Z3950SearchAuth conversion error', @_ ])->Indent(0)->Dump; >+} >+ > 1; > __END__ > >-- >2.25.1
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 33404
:
151510
|
151624
|
151636
|
151641
|
151644
|
151672
|
151673
|
151674
|
151868
|
151869
|
151870
| 153014 |
153015
|
153016