Skip to content

Ensure that entity_loader disable variable is re-set back to the orig… #1585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/PhpWord/Shared/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ 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);
self::$xpath = new \DOMXPath($dom);
$node = $dom->getElementsByTagName('body');

self::parseNode($node->item(0), $element);
libxml_disable_entity_loader($orignalLibEntityLoader);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/PhpWord/TemplateProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/PhpWord/_includes/XmlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down