Skip to content

Commit c3eaf5e

Browse files
Merge pull request #529 from nextcloud/fix/stable20-sabre-parse-xml-errors
[stable20] Update sabre/xml to fix XML parsing errors
2 parents 404e118 + 426af57 commit c3eaf5e

8 files changed

Lines changed: 71 additions & 45 deletions

File tree

composer.lock

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer/installed.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,8 @@
11301130
"homepage": "https://www.doctrine-project.org/projects/reflection.html",
11311131
"keywords": [
11321132
"reflection"
1133-
]
1133+
],
1134+
"abandoned": "roave/better-reflection"
11341135
},
11351136
{
11361137
"name": "egulias/email-validator",
@@ -3971,32 +3972,33 @@
39713972
},
39723973
{
39733974
"name": "sabre/xml",
3974-
"version": "2.2.0",
3975-
"version_normalized": "2.2.0.0",
3975+
"version": "2.2.3",
3976+
"version_normalized": "2.2.3.0",
39763977
"source": {
39773978
"type": "git",
39783979
"url": "https://github.com/sabre-io/xml.git",
3979-
"reference": "705f5cbf7f4fb1e3dd47173e3f026892818c8d46"
3980+
"reference": "c3b959f821c19b36952ec4a595edd695c216bfc6"
39803981
},
39813982
"dist": {
39823983
"type": "zip",
3983-
"url": "https://api.github.com/repos/sabre-io/xml/zipball/705f5cbf7f4fb1e3dd47173e3f026892818c8d46",
3984-
"reference": "705f5cbf7f4fb1e3dd47173e3f026892818c8d46",
3984+
"url": "https://api.github.com/repos/sabre-io/xml/zipball/c3b959f821c19b36952ec4a595edd695c216bfc6",
3985+
"reference": "c3b959f821c19b36952ec4a595edd695c216bfc6",
39853986
"shasum": ""
39863987
},
39873988
"require": {
39883989
"ext-dom": "*",
39893990
"ext-xmlreader": "*",
39903991
"ext-xmlwriter": "*",
39913992
"lib-libxml": ">=2.6.20",
3992-
"php": "^7.1",
3993+
"php": "^7.1 || ^8.0",
39933994
"sabre/uri": ">=1.0,<3.0.0"
39943995
},
39953996
"require-dev": {
39963997
"friendsofphp/php-cs-fixer": "~2.16.1",
3997-
"phpunit/phpunit": "^7 || ^8"
3998+
"phpstan/phpstan": "^0.12",
3999+
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.0"
39984000
},
3999-
"time": "2020-01-31T18:52:58+00:00",
4001+
"time": "2020-10-03T10:08:14+00:00",
40004002
"type": "library",
40014003
"installation-source": "dist",
40024004
"autoload": {

sabre/xml/.gitignore

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,4 @@ composer.lock
55
# Tests
66
tests/cov
77
tests/.phpunit.result.cache
8-
.*.swp
9-
10-
# Composer binaries
11-
bin/phpunit
12-
bin/php-cs-fixer
13-
bin/phpstan
14-
bin/phpstan.phar
15-
16-
# Vim
17-
.*.swp
18-
19-
# IDEs
20-
/.idea
21-
228
.php_cs.cache

sabre/xml/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
ChangeLog
22
=========
33

4+
2.2.3 (2020-10-03)
5+
------------------
6+
* #191: add changelog and version bump that was missed in 2.2.2
7+
8+
2.2.2 (2020-10-03)
9+
------------------
10+
* #190: adjust libxml_disable_entity_loader calls ready for PHP 8.0 (@phil-davis)
11+
12+
2.2.1 (2020-05-11)
13+
------------------
14+
15+
* #183: fixed warning 'xml cannot be empty while reading', which might lead to a infinite-loop (@mrow4a)
16+
* #179, #178, #177 #176: several build/continous integration related improvements (@phil-davis)
17+
418
2.2.0 (2020-01-31)
519
------------------
620

sabre/xml/composer.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"homepage" : "https://sabre.io/xml/",
66
"license" : "BSD-3-Clause",
77
"require" : {
8-
"php" : "^7.1",
8+
"php" : "^7.1 || ^8.0",
99
"ext-xmlwriter" : "*",
1010
"ext-xmlreader" : "*",
1111
"ext-dom" : "*",
@@ -45,9 +45,23 @@
4545
},
4646
"require-dev": {
4747
"friendsofphp/php-cs-fixer": "~2.16.1",
48-
"phpunit/phpunit" : "^7 || ^8"
48+
"phpstan/phpstan": "^0.12",
49+
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0"
4950
},
50-
"config" : {
51-
"bin-dir" : "bin/"
51+
"scripts": {
52+
"phpstan": [
53+
"phpstan analyse lib tests"
54+
],
55+
"cs-fixer": [
56+
"php-cs-fixer fix"
57+
],
58+
"phpunit": [
59+
"phpunit --configuration tests/phpunit.xml"
60+
],
61+
"test": [
62+
"composer phpstan",
63+
"composer cs-fixer",
64+
"composer phpunit"
65+
]
5266
}
5367
}

sabre/xml/lib/Reader.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public function getClark()
5555
*/
5656
public function parse(): array
5757
{
58-
$previousEntityState = libxml_disable_entity_loader(true);
58+
$previousEntityState = null;
59+
$shouldCallLibxmlDisableEntityLoader = (\PHP_VERSION_ID < 80000);
60+
if ($shouldCallLibxmlDisableEntityLoader) {
61+
$previousEntityState = libxml_disable_entity_loader(true);
62+
}
5963
$previousSetting = libxml_use_internal_errors(true);
6064

6165
try {
@@ -78,7 +82,9 @@ public function parse(): array
7882
}
7983
} finally {
8084
libxml_use_internal_errors($previousSetting);
81-
libxml_disable_entity_loader($previousEntityState);
85+
if ($shouldCallLibxmlDisableEntityLoader) {
86+
libxml_disable_entity_loader($previousEntityState);
87+
}
8288
}
8389

8490
return $result;

sabre/xml/lib/Service.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ public function parse($input, string $contextUri = null, string &$rootElementNam
115115
// Unfortunately the XMLReader doesn't support streams. When it
116116
// does, we can optimize this.
117117
$input = (string) stream_get_contents($input);
118+
}
118119

119-
// If input is an empty string, then its safe to throw exception
120-
if ('' === $input) {
121-
throw new ParseException('The input element to parse is empty. Do not attempt to parse');
122-
}
120+
// If input is empty, then its safe to throw exception
121+
if (empty($input)) {
122+
throw new ParseException('The input element to parse is empty. Do not attempt to parse');
123123
}
124+
124125
$r = $this->getReader();
125126
$r->contextUri = $contextUri;
126127
$r->XML($input, null, $this->options);
@@ -158,12 +159,13 @@ public function expect($rootElementName, $input, string $contextUri = null)
158159
// Unfortunately the XMLReader doesn't support streams. When it
159160
// does, we can optimize this.
160161
$input = (string) stream_get_contents($input);
162+
}
161163

162-
// If input is empty string, then its safe to throw exception
163-
if ('' === $input) {
164-
throw new ParseException('The input element to parse is empty. Do not attempt to parse');
165-
}
164+
// If input is empty, then its safe to throw exception
165+
if (empty($input)) {
166+
throw new ParseException('The input element to parse is empty. Do not attempt to parse');
166167
}
168+
167169
$r = $this->getReader();
168170
$r->contextUri = $contextUri;
169171
$r->XML($input, null, $this->options);

sabre/xml/lib/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ class Version
1616
/**
1717
* Full version number.
1818
*/
19-
const VERSION = '2.2.0';
19+
const VERSION = '2.2.3';
2020
}

0 commit comments

Comments
 (0)