Skip to content
Snippets Groups Projects
Commit 6a614913 authored by Jaime Perez's avatar Jaime Perez
Browse files

Fail gracefully while parsing EntitiesDescriptor in the metarefresh module....

Fail gracefully while parsing EntitiesDescriptor in the metarefresh module. Now only the offending entity is disregarded. Fixes #70.
parent ae3743be
No related branches found
No related tags found
No related merge requests found
...@@ -217,7 +217,31 @@ class sspmod_metarefresh_MetaLoader { ...@@ -217,7 +217,31 @@ class sspmod_metarefresh_MetaLoader {
throw new Exception('Failed to read XML from ' . $source['src']); throw new Exception('Failed to read XML from ' . $source['src']);
} }
if($doc->documentElement === NULL) throw new Exception('Opened file is not an XML document: ' . $source['src']); if($doc->documentElement === NULL) throw new Exception('Opened file is not an XML document: ' . $source['src']);
$entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement($doc->documentElement);
if (SimpleSAML_Utilities::isDOMElementOfType($doc->documentElement, 'EntitiesDescriptor', '@md') === TRUE) {
foreach (SAML2_Utils::xpQuery($doc->documentElement,
'./saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) {
if ($node->localName === 'EntityDescriptor') {
try {
$entities = array_merge($entities,
SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement($node));
} catch (Exception $e) {
$entityID = $node->getAttribute('entityID');
if (empty($entityID)) {
$entityID = "unknown";
}
SimpleSAML_Logger::warning('[metarefresh]: Error while parsing entity ('.$entityID.'): '.
$e->getMessage());
}
} else {
$entities = array_merge($entities, $this->loadXML($node->ownerDocument->saveXML($node), $source));
}
}
} else {
$entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement($doc->documentElement);
}
return $entities; return $entities;
} }
......
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