diff --git a/module/VuFind/src/VuFind/RecordDriver/MarcAdvancedTrait.php b/module/VuFind/src/VuFind/RecordDriver/MarcAdvancedTrait.php index 5d0bd86e54e35cb874956d0a8394411f34944c75..a470005933dbc05a523d39888aef80c78642a74f 100644 --- a/module/VuFind/src/VuFind/RecordDriver/MarcAdvancedTrait.php +++ b/module/VuFind/src/VuFind/RecordDriver/MarcAdvancedTrait.php @@ -853,11 +853,15 @@ trait MarcAdvancedTrait { // Special case for MARC: if ($format == 'marc21') { - $xml = $this->getMarcRecord()->toXML(); - $xml = str_replace( - [chr(27), chr(28), chr(29), chr(30), chr(31), chr(8)], ' ', $xml + $sanitizeXmlRegEx + = '[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+'; + $xml = simplexml_load_string( + trim( + preg_replace( + "/$sanitizeXmlRegEx/u", ' ', $this->getMarcRecord()->toXML() + ) + ) ); - $xml = simplexml_load_string($xml); if (!$xml || !isset($xml->record)) { return false; } diff --git a/module/VuFind/src/VuFind/XSLT/Processor.php b/module/VuFind/src/VuFind/XSLT/Processor.php index df99053ad84eb9d722cd06370bd1e62cf76a20e6..38ca7469161c86b4bed2265779f033506a0db857 100644 --- a/module/VuFind/src/VuFind/XSLT/Processor.php +++ b/module/VuFind/src/VuFind/XSLT/Processor.php @@ -58,7 +58,10 @@ class Processor $xsl = new XSLTProcessor(); $xsl->importStyleSheet($style); $doc = new DOMDocument(); - if ($doc->loadXML($xml)) { + $sanitizeXmlRegEx + = '[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+'; + $cleanXml = trim(preg_replace("/$sanitizeXmlRegEx/u", ' ', $xml)); + if ($doc->loadXML($cleanXml)) { foreach ($params as $key => $value) { $xsl->setParameter('', $key, $value); }