From 156a6bb1a0394ce9c506127744c3031e6913c14c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Wed, 5 Jan 2011 11:45:52 +0100 Subject: [PATCH] Bug 3212 Force leader 9 position to 'a' for new biblios When Creating a new biblio record, if the cataloguer doesn't use the leader plugin, a biblio record can be saved with a leader not containing a 'a' in 9 position. If the biblio contains UTF-8 characters, its decoding can fail. This issue applies to MARC-21 not UNIMARC. Signed-off-by: Chris Cormack (cherry picked from commit f1f36a0c940fa53a5671b379a31d77c2cbe40a7f) Signed-off-by: Chris Nighswonger --- C4/Biblio.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 923d767b45..67be2d7857 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1901,8 +1901,13 @@ sub TransformHtmlToMarc { if ( $tag < 10 ) { # no code for theses fields # in MARC editor, 000 contains the leader. if ( $tag eq '000' ) { - $record->leader( $cgi->param( $params->[ $j + 1 ] ) ) if length( $cgi->param( $params->[ $j + 1 ] ) ) == 24; - + # Force a fake leader even if not provided to avoid crashing + # during decoding MARC record containing UTF-8 characters + $record->leader( + length( $cgi->param($params->[$j+1]) ) == 24 + ? $cgi->param( $params->[ $j + 1 ] ) + : ' nam a22 4500' + ; # between 001 and 009 (included) } elsif ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) { $newfield = MARC::Field->new( $tag, $cgi->param( $params->[ $j + 1 ] ), ); -- 2.39.5