Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd60d4e0

Browse files
committed
force enabling the external XML entity loaders
1 parent00763f6 commitd60d4e0

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ private function processAnonymousServices(\DOMDocument $xml, $file)
315315
foreach ($definitionsas$id =>$def) {
316316
list($domElement,$file,$wild) =$def;
317317

318-
319318
if (null !==$definition =$this->parseDefinition($domElement,$file)) {
320319
$this->container->setDefinition($id,$definition);
321320
}
@@ -485,7 +484,9 @@ public function validateSchema(\DOMDocument $dom)
485484
EOF
486485
;
487486

487+
$disableEntities =libxml_disable_entity_loader(false);
488488
$valid = @$dom->schemaValidateSource($source);
489+
libxml_disable_entity_loader($disableEntities);
489490

490491
foreach ($tmpfilesas$tmpfile) {
491492
@unlink($tmpfile);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ public function testParseFile()
8484
$this->assertInstanceOf('DOMDocument',$xml,'->parseFileToDOM() returns an SimpleXMLElement object');
8585
}
8686

87+
publicfunctiontestLoadWithExternalEntitiesDisabled()
88+
{
89+
$disableEntities =libxml_disable_entity_loader(true);
90+
91+
$containerBuilder =newContainerBuilder();
92+
$loader =newXmlFileLoader($containerBuilder,newFileLocator(self::$fixturesPath.'/xml'));
93+
$loader->load('services2.xml');
94+
95+
libxml_disable_entity_loader($disableEntities);
96+
97+
$this->assertTrue(count($containerBuilder->getParameterBag()->all()) >0,'Parameters can be read from the config file.');
98+
}
99+
87100
publicfunctiontestLoadParameters()
88101
{
89102
$container =newContainerBuilder();

‎src/Symfony/Component/Translation/Loader/XliffFileLoader.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,14 @@ private function parseFile($file)
143143
$source =file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-1.2-strict.xsd');
144144
$source =str_replace('http://www.w3.org/2001/xml.xsd',$location,$source);
145145

146+
$disableEntities =libxml_disable_entity_loader(false);
147+
146148
if (!@$dom->schemaValidateSource($source)) {
147149
thrownewInvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s',$file,implode("\n",$this->getXmlErrors($internalErrors))));
148150
}
149151

152+
libxml_disable_entity_loader($disableEntities);
153+
150154
$dom->normalizeDocument();
151155

152156
libxml_clear_errors();

‎src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ public function testLoadWithInternalErrorsEnabled()
4646
libxml_use_internal_errors($internalErrors);
4747
}
4848

49+
publicfunctiontestLoadWithExternalEntitiesDisabled()
50+
{
51+
$disableEntities =libxml_disable_entity_loader(true);
52+
53+
$loader =newXliffFileLoader();
54+
$resource =__DIR__.'/../fixtures/resources.xlf';
55+
$catalogue =$loader->load($resource,'en','domain1');
56+
57+
libxml_disable_entity_loader($disableEntities);
58+
59+
$this->assertEquals('en',$catalogue->getLocale());
60+
$this->assertEquals(array(newFileResource($resource)),$catalogue->getResources());
61+
}
62+
4963
publicfunctiontestLoadWithResname()
5064
{
5165
$loader =newXliffFileLoader();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp