From 539ab36561a823b75ee2c1e353afbd758a94040a Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 23 Nov 2020 10:25:30 +0100 Subject: [PATCH] Update sabre/xml to fix XML parsing errors Signed-off-by: Christoph Wurst --- composer.lock | 16 +++++++++------- composer/installed.json | 20 +++++++++++--------- sabre/xml/.gitignore | 14 -------------- sabre/xml/CHANGELOG.md | 14 ++++++++++++++ sabre/xml/composer.json | 22 ++++++++++++++++++---- sabre/xml/lib/Reader.php | 10 ++++++++-- sabre/xml/lib/Service.php | 18 ++++++++++-------- sabre/xml/lib/Version.php | 2 +- 8 files changed, 71 insertions(+), 45 deletions(-) diff --git a/composer.lock b/composer.lock index ebb35fbfa..158561c11 100644 --- a/composer.lock +++ b/composer.lock @@ -1056,6 +1056,7 @@ "keywords": [ "reflection" ], + "abandoned": "roave/better-reflection", "time": "2018-06-14T14:45:07+00:00" }, { @@ -3803,16 +3804,16 @@ }, { "name": "sabre/xml", - "version": "2.2.0", + "version": "2.2.3", "source": { "type": "git", "url": "https://github.com/sabre-io/xml.git", - "reference": "705f5cbf7f4fb1e3dd47173e3f026892818c8d46" + "reference": "c3b959f821c19b36952ec4a595edd695c216bfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/xml/zipball/705f5cbf7f4fb1e3dd47173e3f026892818c8d46", - "reference": "705f5cbf7f4fb1e3dd47173e3f026892818c8d46", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/c3b959f821c19b36952ec4a595edd695c216bfc6", + "reference": "c3b959f821c19b36952ec4a595edd695c216bfc6", "shasum": "" }, "require": { @@ -3820,12 +3821,13 @@ "ext-xmlreader": "*", "ext-xmlwriter": "*", "lib-libxml": ">=2.6.20", - "php": "^7.1", + "php": "^7.1 || ^8.0", "sabre/uri": ">=1.0,<3.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit": "^7 || ^8" + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" }, "type": "library", "autoload": { @@ -3862,7 +3864,7 @@ "dom", "xml" ], - "time": "2020-01-31T18:52:58+00:00" + "time": "2020-10-03T10:08:14+00:00" }, { "name": "scssphp/scssphp", diff --git a/composer/installed.json b/composer/installed.json index fa58feafe..3b2306c6c 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1081,7 +1081,8 @@ "homepage": "https://www.doctrine-project.org/projects/reflection.html", "keywords": [ "reflection" - ] + ], + "abandoned": "roave/better-reflection" }, { "name": "egulias/email-validator", @@ -3922,17 +3923,17 @@ }, { "name": "sabre/xml", - "version": "2.2.0", - "version_normalized": "2.2.0.0", + "version": "2.2.3", + "version_normalized": "2.2.3.0", "source": { "type": "git", "url": "https://github.com/sabre-io/xml.git", - "reference": "705f5cbf7f4fb1e3dd47173e3f026892818c8d46" + "reference": "c3b959f821c19b36952ec4a595edd695c216bfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sabre-io/xml/zipball/705f5cbf7f4fb1e3dd47173e3f026892818c8d46", - "reference": "705f5cbf7f4fb1e3dd47173e3f026892818c8d46", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/c3b959f821c19b36952ec4a595edd695c216bfc6", + "reference": "c3b959f821c19b36952ec4a595edd695c216bfc6", "shasum": "" }, "require": { @@ -3940,14 +3941,15 @@ "ext-xmlreader": "*", "ext-xmlwriter": "*", "lib-libxml": ">=2.6.20", - "php": "^7.1", + "php": "^7.1 || ^8.0", "sabre/uri": ">=1.0,<3.0.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit": "^7 || ^8" + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" }, - "time": "2020-01-31T18:52:58+00:00", + "time": "2020-10-03T10:08:14+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/sabre/xml/.gitignore b/sabre/xml/.gitignore index a85591183..9715e9028 100644 --- a/sabre/xml/.gitignore +++ b/sabre/xml/.gitignore @@ -5,18 +5,4 @@ composer.lock # Tests tests/cov tests/.phpunit.result.cache -.*.swp - -# Composer binaries -bin/phpunit -bin/php-cs-fixer -bin/phpstan -bin/phpstan.phar - -# Vim -.*.swp - -# IDEs -/.idea - .php_cs.cache diff --git a/sabre/xml/CHANGELOG.md b/sabre/xml/CHANGELOG.md index bbfc8ddec..cdd21fe51 100644 --- a/sabre/xml/CHANGELOG.md +++ b/sabre/xml/CHANGELOG.md @@ -1,6 +1,20 @@ ChangeLog ========= +2.2.3 (2020-10-03) +------------------ +* #191: add changelog and version bump that was missed in 2.2.2 + +2.2.2 (2020-10-03) +------------------ +* #190: adjust libxml_disable_entity_loader calls ready for PHP 8.0 (@phil-davis) + +2.2.1 (2020-05-11) +------------------ + +* #183: fixed warning 'xml cannot be empty while reading', which might lead to a infinite-loop (@mrow4a) +* #179, #178, #177 #176: several build/continous integration related improvements (@phil-davis) + 2.2.0 (2020-01-31) ------------------ diff --git a/sabre/xml/composer.json b/sabre/xml/composer.json index 2af0dd458..b54cf195b 100644 --- a/sabre/xml/composer.json +++ b/sabre/xml/composer.json @@ -5,7 +5,7 @@ "homepage" : "https://sabre.io/xml/", "license" : "BSD-3-Clause", "require" : { - "php" : "^7.1", + "php" : "^7.1 || ^8.0", "ext-xmlwriter" : "*", "ext-xmlreader" : "*", "ext-dom" : "*", @@ -45,9 +45,23 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "~2.16.1", - "phpunit/phpunit" : "^7 || ^8" + "phpstan/phpstan": "^0.12", + "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0" }, - "config" : { - "bin-dir" : "bin/" + "scripts": { + "phpstan": [ + "phpstan analyse lib tests" + ], + "cs-fixer": [ + "php-cs-fixer fix" + ], + "phpunit": [ + "phpunit --configuration tests/phpunit.xml" + ], + "test": [ + "composer phpstan", + "composer cs-fixer", + "composer phpunit" + ] } } diff --git a/sabre/xml/lib/Reader.php b/sabre/xml/lib/Reader.php index a28cf8c3b..368e8ffd2 100644 --- a/sabre/xml/lib/Reader.php +++ b/sabre/xml/lib/Reader.php @@ -55,7 +55,11 @@ public function getClark() */ public function parse(): array { - $previousEntityState = libxml_disable_entity_loader(true); + $previousEntityState = null; + $shouldCallLibxmlDisableEntityLoader = (\PHP_VERSION_ID < 80000); + if ($shouldCallLibxmlDisableEntityLoader) { + $previousEntityState = libxml_disable_entity_loader(true); + } $previousSetting = libxml_use_internal_errors(true); try { @@ -78,7 +82,9 @@ public function parse(): array } } finally { libxml_use_internal_errors($previousSetting); - libxml_disable_entity_loader($previousEntityState); + if ($shouldCallLibxmlDisableEntityLoader) { + libxml_disable_entity_loader($previousEntityState); + } } return $result; diff --git a/sabre/xml/lib/Service.php b/sabre/xml/lib/Service.php index 9a2c47794..596c93cc4 100644 --- a/sabre/xml/lib/Service.php +++ b/sabre/xml/lib/Service.php @@ -115,12 +115,13 @@ public function parse($input, string $contextUri = null, string &$rootElementNam // Unfortunately the XMLReader doesn't support streams. When it // does, we can optimize this. $input = (string) stream_get_contents($input); + } - // If input is an empty string, then its safe to throw exception - if ('' === $input) { - throw new ParseException('The input element to parse is empty. Do not attempt to parse'); - } + // If input is empty, then its safe to throw exception + if (empty($input)) { + throw new ParseException('The input element to parse is empty. Do not attempt to parse'); } + $r = $this->getReader(); $r->contextUri = $contextUri; $r->XML($input, null, $this->options); @@ -158,12 +159,13 @@ public function expect($rootElementName, $input, string $contextUri = null) // Unfortunately the XMLReader doesn't support streams. When it // does, we can optimize this. $input = (string) stream_get_contents($input); + } - // If input is empty string, then its safe to throw exception - if ('' === $input) { - throw new ParseException('The input element to parse is empty. Do not attempt to parse'); - } + // If input is empty, then its safe to throw exception + if (empty($input)) { + throw new ParseException('The input element to parse is empty. Do not attempt to parse'); } + $r = $this->getReader(); $r->contextUri = $contextUri; $r->XML($input, null, $this->options); diff --git a/sabre/xml/lib/Version.php b/sabre/xml/lib/Version.php index cf2810c2a..d4e465de9 100644 --- a/sabre/xml/lib/Version.php +++ b/sabre/xml/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - const VERSION = '2.2.0'; + const VERSION = '2.2.3'; }