From 66a7c25403b9f9f71e8d1eda7a0b36c6f2ab34a0 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 24 Feb 2019 07:53:24 +1100 Subject: [PATCH] Upgrade PHPWord Patch phpword install to fix global handling of disable libxml entity loader Fix phpoffice/common as well --- composer.json | 15 ++- composer.lock | 109 +++++++++++++----- .../phpoffice-common-xml-entity-fix.patch | 15 +++ .../phpword-libxml-fix-global-handling.patch | 51 ++++++++ 4 files changed, 157 insertions(+), 33 deletions(-) create mode 100644 tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch create mode 100644 tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch diff --git a/composer.json b/composer.json index 167b56a9a4..0a2bb8786f 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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": [ { @@ -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" + } + } } } diff --git a/composer.lock b/composer.lock index f998fe0c80..5e4c864c04 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d87e8c07e37c51a65ff849235d04e3dc", + "content-hash": "55c8f835d55c424d93e0e9dad1efc729", "packages": [ { "name": "civicrm/civicrm-cxn-rpc", @@ -80,6 +80,50 @@ "description": "CiviCRM installation library", "time": "2018-01-23T06:26:55+00:00" }, + { + "name": "cweagans/composer-patches", + "version": "1.6.5", + "source": { + "type": "git", + "url": "https://github.com/cweagans/composer-patches.git", + "reference": "2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3", + "reference": "2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": ">=5.3.0" + }, + "require-dev": { + "composer/composer": "~1.0", + "phpunit/phpunit": "~4.6" + }, + "type": "composer-plugin", + "extra": { + "class": "cweagans\\Composer\\Patches" + }, + "autoload": { + "psr-4": { + "cweagans\\Composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Cameron Eagans", + "email": "me@cweagans.net" + } + ], + "description": "Provides a way to patch Composer packages.", + "time": "2018-05-11T18:00:16+00:00" + }, { "name": "dompdf/dompdf", "version": "v0.8.0", @@ -110,9 +154,6 @@ "extra": { "branch-alias": { "dev-develop": "0.7-dev" - }, - "patches_applied": { - "Fix Fatal error: Uncaught Dompdf Exception: No block-level parent found.": "tools/scripts/composer/patches/dompdf_no_block_level_parent_fix.patch" } }, "autoload": { @@ -634,14 +675,6 @@ "pear/auth_sasl": "Install optionally via your project's composer.json" }, "type": "library", - "extra": { - "patches_applied": { - "CRM-8744 Display CiviCRM Specific error message": "tools/scripts/composer/patches/net-smtp-patch.patch", - "Fix PHP7 Compliance": "tools/scripts/composer/patches/net-smtp-php7-patch.patch", - "Fix Pass by reference issues": "tools/scripts/composer/patches/net-smtp-ref-patch.patch", - "Fix TLS support issue in PHP5.6": "tools/scripts/composer/patches/net-smtp-tls-patch.patch" - } - }, "autoload": { "psr-0": { "Net": "./" @@ -948,16 +981,16 @@ }, { "name": "phpoffice/common", - "version": "v0.2.6", + "version": "0.2.9", "source": { "type": "git", "url": "https://github.com/PHPOffice/Common.git", - "reference": "c9be70c80637c28c728be78e66aad4878a34f8dd" + "reference": "edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/Common/zipball/c9be70c80637c28c728be78e66aad4878a34f8dd", - "reference": "c9be70c80637c28c728be78e66aad4878a34f8dd", + "url": "https://api.github.com/repos/PHPOffice/Common/zipball/edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d", + "reference": "edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d", "shasum": "" }, "require": { @@ -968,11 +1001,16 @@ "phpdocumentor/phpdocumentor": "2.*", "phploc/phploc": "2.*", "phpmd/phpmd": "2.*", - "phpunit/phpunit": "3.7.*", + "phpunit/phpunit": "^4.8.36 || ^7.0", "sebastian/phpcpd": "2.*", "squizlabs/php_codesniffer": "2.*" }, "type": "library", + "extra": { + "patches_applied": { + "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch" + } + }, "autoload": { "psr-4": { "PhpOffice\\Common\\": "src/Common/" @@ -999,38 +1037,39 @@ "office", "php" ], - "time": "2016-07-07T17:26:55+00:00" + "time": "2018-07-13T14:12:34+00:00" }, { "name": "phpoffice/phpword", - "version": "v0.14.0", + "version": "0.15.0", "source": { "type": "git", "url": "https://github.com/PHPOffice/PHPWord.git", - "reference": "b614497ae6dd44280be1c2dda56772198bcd25ae" + "reference": "dfa2f36cad2b632b7ab1c56473e4f5db9a7caf7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/b614497ae6dd44280be1c2dda56772198bcd25ae", - "reference": "b614497ae6dd44280be1c2dda56772198bcd25ae", + "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/dfa2f36cad2b632b7ab1c56473e4f5db9a7caf7f", + "reference": "dfa2f36cad2b632b7ab1c56473e4f5db9a7caf7f", "shasum": "" }, "require": { "ext-xml": "*", "php": "^5.3.3 || ^7.0", - "phpoffice/common": "^0.2", - "zendframework/zend-escaper": "^2.2", - "zendframework/zend-stdlib": "^2.2 || ^3.0" + "phpoffice/common": "^0.2.9", + "zendframework/zend-escaper": "^2.2" }, "require-dev": { "dompdf/dompdf": "0.8.*", - "friendsofphp/php-cs-fixer": "^2.0", - "mpdf/mpdf": "5.* || 6.* || 7.*", - "phpdocumentor/phpdocumentor": "2.*", + "ext-gd": "*", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^2.2", + "mpdf/mpdf": "5.7.4 || 6.* || 7.*", + "php-coveralls/php-coveralls": "1.1.0 || ^2.0", "phploc/phploc": "2.* || 3.* || 4.*", "phpmd/phpmd": "2.*", - "phpunit/phpunit": "^4.8.36 || ^5.0", - "squizlabs/php_codesniffer": "^2.7", + "phpunit/phpunit": "^4.8.36 || ^7.0", + "squizlabs/php_codesniffer": "^2.9", "tecnickcom/tcpdf": "6.*" }, "suggest": { @@ -1041,6 +1080,14 @@ "ext-zip": "Allows writing OOXML and ODF" }, "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.16-dev" + }, + "patches_applied": { + "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch" + } + }, "autoload": { "psr-4": { "PhpOffice\\PhpWord\\": "src/PhpWord" @@ -1102,7 +1149,7 @@ "word", "writer" ], - "time": "2017-12-29T01:30:53+00:00" + "time": "2018-07-14T16:59:43+00:00" }, { "name": "phpseclib/phpseclib", diff --git a/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch b/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch new file mode 100644 index 0000000000..c3da55e120 --- /dev/null +++ b/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch @@ -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; + } + diff --git a/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch b/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch new file mode 100644 index 0000000000..da6f8f0c4c --- /dev/null +++ b/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch @@ -0,0 +1,51 @@ +From 27ee4bef48def2e3b966b6d5ff8cc8c56b1fac2c Mon Sep 17 00:00:00 2001 +From: Seamus Lee +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; + } -- 2.25.1