diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 89881822ca..f2710ea168 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -72,7 +72,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit } // Load DOM - libxml_disable_entity_loader(true); + $orignalLibEntityLoader = libxml_disable_entity_loader(true); $dom = new \DOMDocument(); $dom->preserveWhiteSpace = $preserveWhiteSpace; $dom->loadXML($html); @@ -80,6 +80,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit $node = $dom->getElementsByTagName('body'); self::parseNode($node->item(0), $element); + libxml_disable_entity_loader($orignalLibEntityLoader); } /** diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 0f685bc45b..7efc0f1ac8 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -170,7 +170,7 @@ protected function readPartWithRels($fileName) */ protected function transformSingleXml($xml, $xsltProcessor) { - libxml_disable_entity_loader(true); + $orignalLibEntityLoader = libxml_disable_entity_loader(true); $domDocument = new \DOMDocument(); if (false === $domDocument->loadXML($xml)) { throw new Exception('Could not load the given XML document.'); @@ -180,6 +180,7 @@ protected function transformSingleXml($xml, $xsltProcessor) if (false === $transformedXml) { throw new Exception('Could not transform the given XML document.'); } + libxml_disable_entity_loader($orignalLibEntityLoader); return $transformedXml; } diff --git a/tests/PhpWord/_includes/XmlDocument.php b/tests/PhpWord/_includes/XmlDocument.php index f51eaad82c..3a7869bcea 100644 --- a/tests/PhpWord/_includes/XmlDocument.php +++ b/tests/PhpWord/_includes/XmlDocument.php @@ -76,10 +76,10 @@ public function getFileDom($file = 'word/document.xml') $this->file = $file; $file = $this->path . '/' . $file; - libxml_disable_entity_loader(false); + $orignalLibEntityLoader = libxml_disable_entity_loader(false); $this->dom = new \DOMDocument(); $this->dom->load($file); - libxml_disable_entity_loader(true); + libxml_disable_entity_loader($orignalLibEntityLoader); return $this->dom; }