Skip to content
Snippets Groups Projects
Commit f683b74e authored by Olav Morken's avatar Olav Morken
Browse files

Utilities: Updated validateXML to use the new SimpleSAML_XML_Errors class.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@678 44740490-163a-0410-bde0-09ae8108e29a
parent 09a9fb46
No related branches found
No related tags found
No related merge requests found
...@@ -760,8 +760,7 @@ class SimpleSAML_Utilities { ...@@ -760,8 +760,7 @@ class SimpleSAML_Utilities {
assert('is_string($message)'); assert('is_string($message)');
assert('is_string($schema)'); assert('is_string($schema)');
$xmlErrorState = libxml_use_internal_errors(TRUE); SimpleSAML_XML_Errors::begin();
libxml_clear_errors();
$dom = new DOMDocument; $dom = new DOMDocument;
$res = $dom->loadXML($message); $res = $dom->loadXML($message);
...@@ -773,20 +772,17 @@ class SimpleSAML_Utilities { ...@@ -773,20 +772,17 @@ class SimpleSAML_Utilities {
$res = $dom->schemaValidate($schemaFile); $res = $dom->schemaValidate($schemaFile);
if($res) { if($res) {
libxml_use_internal_errors($xmlErrorState); SimpleSAML_XML_Errors::end();
return ''; return '';
} }
$errorText = 'Schema validation failed on XML string:'; $errorText = "Schema validation failed on XML string:\n";
} else { } else {
$errorText = 'Failed to parse XML string for schema validation:'; $errorText = "Failed to parse XML string for schema validation:\n";
} }
$errors = libxml_get_errors(); $errors = SimpleSAML_XML_Errors::end();
foreach($errors as $error) { $errorText .= SimpleSAML_XML_Errors::formatErrors($errors);
$errorText .= ' [' . $error->level . ':' . $error->code . '@'
. $error->line . ',' . $error->column . ' ' . trim($error->message) . ']';
}
return $errorText; return $errorText;
} }
......
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