-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch phpword install to fix global handling of disable libxml entity loader Fix phpoffice/common as well
- Loading branch information
1 parent
58ef76b
commit 66a7c25
Showing
4 changed files
with
157 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- src/Common/XMLReader.php 2019-02-24 13:35:42.895637978 +1100 | ||
+++ src/Common/XMLReader.php 2019-02-24 11:41:29.462449569 +1100 | ||
@@ -71,10 +71,11 @@ | ||
*/ | ||
public function getDomFromString($content) | ||
{ | ||
+ $original = libxml_disable_entity_loader(); | ||
libxml_disable_entity_loader(true); | ||
$this->dom = new \DOMDocument(); | ||
$this->dom->loadXML($content); | ||
- | ||
+ libxml_disable_entity_loader($original); | ||
return $this->dom; | ||
} | ||
|
51 changes: 51 additions & 0 deletions
51
tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
From 27ee4bef48def2e3b966b6d5ff8cc8c56b1fac2c Mon Sep 17 00:00:00 2001 | ||
From: Seamus Lee <[email protected]> | ||
Date: Sun, 24 Feb 2019 09:06:51 +1100 | ||
Subject: [PATCH] Ensure that entity_loader disable variable is re-set back to | ||
the original setting | ||
|
||
--- | ||
src/PhpWord/Shared/Html.php | 2 ++ | ||
src/PhpWord/TemplateProcessor.php | 2 ++ | ||
3 files changed, 6 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php | ||
index 89881822ca..f25cf5f4a6 100644 | ||
--- a/src/PhpWord/Shared/Html.php | ||
+++ b/src/PhpWord/Shared/Html.php | ||
@@ -72,6 +72,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit | ||
} | ||
|
||
// Load DOM | ||
+ $orignalLibEntityLoader = libxml_disable_entity_loader(); | ||
libxml_disable_entity_loader(true); | ||
$dom = new \DOMDocument(); | ||
$dom->preserveWhiteSpace = $preserveWhiteSpace; | ||
@@ -80,6 +81,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..fa605b19c5 100644 | ||
--- a/src/PhpWord/TemplateProcessor.php | ||
+++ b/src/PhpWord/TemplateProcessor.php | ||
@@ -170,6 +170,7 @@ protected function readPartWithRels($fileName) | ||
*/ | ||
protected function transformSingleXml($xml, $xsltProcessor) | ||
{ | ||
+ $orignalLibEntityLoader = libxml_disable_entity_loader(); | ||
libxml_disable_entity_loader(true); | ||
$domDocument = new \DOMDocument(); | ||
if (false === $domDocument->loadXML($xml)) { | ||
@@ -180,6 +181,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; | ||
} |