8000 bug #18908 [DependencyInjection] force enabling the external XML enti… · src-run/symfony@44f6f89 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44f6f89

Browse files
bug symfony#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 | symfony#18876 | License | MIT | Doc PR | Commits ------- 142b1a4 force enabling the external XML entity loaders
2 parents 57d6053 + 142b1a4 commit 44f6f89

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines 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

Lines 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