LP#1442276 output_as_chars() instead of toString
authorDan Scott <dscott@laurentian.ca>
Sun, 5 Mar 2017 16:45:12 +0000 (11:45 -0500)
committerDan Scott <dscott@laurentian.ca>
Sun, 12 Mar 2017 04:10:05 +0000 (23:10 -0500)
The SuperCat transform methods for records retrieved by record ID or ISBN call
toString on the XSLT output object, which results in a byte string and thus
corrupted output. Instead, call output_as_chars() on the stylesheet object to
generate a character string and avoid corruption.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>

Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm

index 3a8aebe..2715571 100644 (file)
@@ -2688,6 +2688,7 @@ sub retrieve_record_transform {
     my $rid = shift;
 
     (my $transform = $self->api_name) =~ s/^.+record\.([^\.]+)\.retrieve$/$1/o;
+    my $xslt = $record_xslt{$transform}{xslt};
 
     my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
     #$_storage->connect;
@@ -2699,7 +2700,7 @@ sub retrieve_record_transform {
 
     return undef unless ($record);
 
-    return $U->entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
+    return $U->entityize($xslt->output_as_chars($xslt->transform($_parser->parse_string($record->marc))));
 }
 
 sub retrieve_isbn_transform {
@@ -2717,12 +2718,13 @@ sub retrieve_isbn_transform {
     return undef unless (@$recs);
 
     (my $transform = $self->api_name) =~ s/^.+isbn\.([^\.]+)\.retrieve$/$1/o;
+    my $xslt = $record_xslt{$transform}{xslt};
 
     my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $recs->[0]->record )->gather(1);
 
     return undef unless ($record);
 
-    return $U->entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
+    return $U->entityize($xslt->output_as_chars($xslt->transform($_parser->parse_string($record->marc))));
 }
 
 sub retrieve_record_objects {