Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44f6f89

Browse filesBrowse files
bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] force enabling the external XML entity loaders | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18876 | License | MIT | Doc PR | Commits ------- 142b1a4 force enabling the external XML entity loaders
2 parents 57d6053 + 142b1a4 commit 44f6f89
Copy full SHA for 44f6f89

File tree

2 files changed

+15
-0
lines changed
Filter options

2 files changed

+15
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ public function validateSchema(\DOMDocument $dom)
333333
EOF
334334
;
335335

336+
$disableEntities = libxml_disable_entity_loader(false);
336337
$valid = @$dom->schemaValidateSource($source);
338+
libxml_disable_entity_loader($disableEntities);
337339

338340
foreach ($tmpfiles as $tmpfile) {
339341
@unlink($tmpfile);

‎src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ public function testParseFile()
8383
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', $xml, '->parseFile() returns an SimpleXMLElement object');
8484
}
8585

86+
public function testLoaderTurnsOnEntityLoaderIfNecessary()
87+
{
88+
$oldValue = libxml_disable_entity_loader(true);
89+
90+
$containerBuilder = new ContainerBuilder();
91+
$loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml'));
92+
$loader->load('services2.xml');
93+
94+
libxml_disable_entity_loader($oldValue);
95+
96+
$this->assertTrue(count($containerBuilder->getParameterBag()->all()) > 0, 'Parameters can be read from the config file.');
97+
}
98+
8699
public function testLoadParameters()
87100
{
88101
$container = new ContainerBuilder();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.