[open-ils-commits] r16247 - trunk/Open-ILS/src/perlmods/OpenILS/WWW (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Apr 16 00:38:05 EDT 2010


Author: dbs
Date: 2010-04-16 00:38:02 -0400 (Fri, 16 Apr 2010)
New Revision: 16247

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Log:
Prevent possible character corruption or fatal errors in SRU / Z39.50

All MARC records in the Evergreen database are Unicode-encoded. However,
if the LDR09 hasn't been updated to indicate this, when we invoke
MARC::File::XML->as_xml_record it automatically runs a MARC8-to-UTF8 conversion
over the data - potentially corrupting the data, or resulting in fatal
errors. When holdings are added to records in SRU / Z39.50, we invoke
this code path.

The solution here is to simply manually set the leader 09 position to 'a'
before invoking MARC::File::XML->as_xml_record.


Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2010-04-15 21:29:27 UTC (rev 16246)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2010-04-16 04:38:02 UTC (rev 16247)
@@ -1739,7 +1739,7 @@
 			'open-ils.search.biblio.multiclass.query' => {offset => $offset, limit => $limit} => $search_string => 1
 		)->gather(1);
 
-        my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
+		my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
 
 		foreach my $record (@$bre) {
 			my $marcxml = $record->marc;
@@ -1750,6 +1750,13 @@
 				my $bib_holdings = $supercat->request('open-ils.supercat.record.basic_holdings.retrieve', $record->id, $shortname || '-')->gather(1);
 				my $marc = MARC::Record->new_from_xml($marcxml, 'UTF8', 'XML');
 
+				# Force record leader to 'a' as our data is always UTF8
+				# Avoids marc8_to_utf8 from being invoked with horrible results
+				# on the off-chance the record leader isn't correct
+				my $ldr = $marc->leader;
+				substr($ldr, 9, 1, 'a');
+				$marc->leader($ldr);
+
 				# Expects the record ID in the 001
 				$marc->delete_field($_) for ($marc->field('001'));
 				if (!$marc->field('001')) {
@@ -1797,9 +1804,9 @@
 			);
 		}
 
-        $resp->numberOfRecords($recs->{count});
+		$resp->numberOfRecords($recs->{count});
 
-    } elsif ( $resp->type eq 'explain' ) {
+	} elsif ( $resp->type eq 'explain' ) {
 		if (!$ex_doc) {
 			my $host = $cgi->virtual_host || $cgi->server_name;
 
@@ -1864,9 +1871,9 @@
 		);
 	}
 
-   	print $cgi->header( -type => 'application/xml' );
-   	print $U->entityize($resp->asXML) . "\n";
-    return Apache2::Const::OK;
+	print $cgi->header( -type => 'application/xml' );
+	print $U->entityize($resp->asXML) . "\n";
+	return Apache2::Const::OK;
 }
 
 



More information about the open-ils-commits mailing list