force enabling the external XML entity loaders
This commit is contained in:
parent
00763f6e41
commit
12b5509d8b
@ -315,7 +315,6 @@ class XmlFileLoader extends FileLoader
|
||||
foreach ($definitions as $id => $def) {
|
||||
list($domElement, $file, $wild) = $def;
|
||||
|
||||
|
||||
if (null !== $definition = $this->parseDefinition($domElement, $file)) {
|
||||
$this->container->setDefinition($id, $definition);
|
||||
}
|
||||
@ -485,7 +484,9 @@ $imports
|
||||
EOF
|
||||
;
|
||||
|
||||
$disableEntities = libxml_disable_entity_loader(false);
|
||||
$valid = @$dom->schemaValidateSource($source);
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
||||
foreach ($tmpfiles as $tmpfile) {
|
||||
@unlink($tmpfile);
|
||||
|
@ -84,6 +84,19 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('DOMDocument', $xml, '->parseFileToDOM() returns an SimpleXMLElement object');
|
||||
}
|
||||
|
||||
public function testLoadWithExternalEntitiesDisabled()
|
||||
{
|
||||
$disableEntities = libxml_disable_entity_loader(true);
|
||||
|
||||
$containerBuilder = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('services2.xml');
|
||||
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
||||
$this->assertTrue(count($containerBuilder->getParameterBag()->all()) > 0, 'Parameters can be read from the config file.');
|
||||
}
|
||||
|
||||
public function testLoadParameters()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
@ -143,10 +143,16 @@ class XliffFileLoader implements LoaderInterface
|
||||
$source = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-1.2-strict.xsd');
|
||||
$source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source);
|
||||
|
||||
$disableEntities = libxml_disable_entity_loader(false);
|
||||
|
||||
if (!@$dom->schemaValidateSource($source)) {
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
||||
throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s', $file, implode("\n", $this->getXmlErrors($internalErrors))));
|
||||
}
|
||||
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
||||
$dom->normalizeDocument();
|
||||
|
||||
libxml_clear_errors();
|
||||
|
@ -46,6 +46,20 @@ class XliffFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
libxml_use_internal_errors($internalErrors);
|
||||
}
|
||||
|
||||
public function testLoadWithExternalEntitiesDisabled()
|
||||
{
|
||||
$disableEntities = libxml_disable_entity_loader(true);
|
||||
|
||||
$loader = new XliffFileLoader();
|
||||
$resource = __DIR__.'/../fixtures/resources.xlf';
|
||||
$catalogue = $loader->load($resource, 'en', 'domain1');
|
||||
|
||||
libxml_disable_entity_loader($disableEntities);
|
||||
|
||||
$this->assertEquals('en', $catalogue->getLocale());
|
||||
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
||||
}
|
||||
|
||||
public function testLoadWithResname()
|
||||
{
|
||||
$loader = new XliffFileLoader();
|
||||
|
Reference in New Issue
Block a user