Skip to content
Snippets Groups Projects
Commit ea77240b authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

Use a custom XML entity loader

This allows us to still validate XML documents (disabling the entity loader makes it impossible, as we have multiple schemas in different files), while protecting against schemas trying to import from URLs.
parent 00716eb4
No related branches found
No related tags found
No related merge requests found
...@@ -449,6 +449,15 @@ class XML ...@@ -449,6 +449,15 @@ class XML
$schemaPath = $config->resolvePath('schemas'); $schemaPath = $config->resolvePath('schemas');
$schemaFile = $schemaPath . '/' . $schema; $schemaFile = $schemaPath . '/' . $schema;
libxml_set_external_entity_loader(
function ($public, $system, $context) {
if (filter_var($system, FILTER_VALIDATE_URL) === $system) {
return null;
}
return $system;
}
);
$res = $dom->schemaValidate($schemaFile); $res = $dom->schemaValidate($schemaFile);
if ($res) { if ($res) {
Errors::end(); Errors::end();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment