Merge pull request #1585 from seamuslee001/libxml_improve

Ensure that entity_loader disable variable is re-set back to the orig…
This commit is contained in:
troosan 2019-03-31 13:19:25 +02:00 committed by GitHub
commit 6e4f18c2b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -72,7 +72,7 @@ class Html
}
// 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 @@ class Html
$node = $dom->getElementsByTagName('body');
self::parseNode($node->item(0), $element);
libxml_disable_entity_loader($orignalLibEntityLoader);
}
/**

View File

@ -170,7 +170,7 @@ class TemplateProcessor
*/
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 @@ class TemplateProcessor
if (false === $transformedXml) {
throw new Exception('Could not transform the given XML document.');
}
libxml_disable_entity_loader($orignalLibEntityLoader);
return $transformedXml;
}

View File

@ -76,10 +76,10 @@ class XmlDocument
$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;
}