Skip to content
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

Upgrade PHPWord #13686

Merged
merged 1 commit into from
Feb 27, 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
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"zetacomponents/base": "1.7.*",
"zetacomponents/mail": "dev-1.7-civi",
"marcj/topsort": "~1.1",
"phpoffice/phpword": "^0.14.0",
"phpoffice/phpword": "^0.15.0",
"pear/Validate_Finance_CreditCard": "dev-master",
"civicrm/civicrm-cxn-rpc": "~0.19.01.08",
"pear/Auth_SASL": "1.1.0",
Expand All @@ -58,7 +58,8 @@
"pear/mail": "^1.4",
"civicrm/civicrm-setup": "~0.2.0",
"guzzlehttp/guzzle": "^6.3",
"psr/simple-cache": "~1.0.1"
"psr/simple-cache": "~1.0.1",
"cweagans/composer-patches": "~1.0"
},
"repositories": [
{
Expand All @@ -83,5 +84,15 @@
"bash tools/scripts/composer/pear-mail-fix.sh",
"bash tools/scripts/composer/phpword-jquery.sh"
]
},
"extra": {
"patches": {
"phpoffice/common": {
"Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch"
},
"phpoffice/phpword": {
"Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch"
}
}
}
}
109 changes: 78 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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;
}

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;
}