diff --git a/classes/admin/setting_idpmetadata.php b/classes/admin/setting_idpmetadata.php index 2e5763158..404a2ddac 100644 --- a/classes/admin/setting_idpmetadata.php +++ b/classes/admin/setting_idpmetadata.php @@ -210,8 +210,20 @@ public function get_idps_data($value) { */ private function get_idp_xml_path(idp_data $idp) { $xml = new DOMDocument(); - if (!$xml->loadXML($idp->rawxml)) { - throw new setting_idpmetadata_exception(get_string('idpmetadata_invalid', 'auth_saml2')); + + libxml_use_internal_errors(true); + + $rawxml = $idp->rawxml; + + if (!$xml->loadXML($rawxml)) { + $errors = libxml_get_errors(); + $lines = explode("\n", $rawxml); + $msg = ''; + foreach ($errors as $error) { + $msg .= "
Error ({$error->code}) line $error->line char $error->column: $error->message"; + } + + throw new setting_idpmetadata_exception(get_string('idpmetadata_invalid', 'auth_saml2') . $msg); } $xpath = new DOMXPath($xml); diff --git a/classes/idp_parser.php b/classes/idp_parser.php index a38aa4c75..3cc0af958 100644 --- a/classes/idp_parser.php +++ b/classes/idp_parser.php @@ -56,7 +56,18 @@ public function parse($data) { return $this->idps; } + /** + * Does the field *look* like xml, mostly? + */ public function check_xml($xml) { + + $declaration = '