Replace SimpleXml by Mediawiki library

This replaces the SimpleXML library by
the internal class XmlTypeCheck

Needs at least that version
 https://gerrit.wikimedia.org/r/#/c/66365/

Change-Id: Iafbd820f7130c8eb8d4f19824632b4ac89f214a9
This commit is contained in:
physikerwelt 2013-06-07 23:43:45 +00:00 committed by Gerrit Code Review
parent 461d31718d
commit 233d285264
1 changed files with 5 additions and 9 deletions

View File

@ -204,23 +204,19 @@ class MathLaTeXML extends MathRenderer {
*/
static public function isValidMathML( $XML ) {
$out = false;
$prevInternalErrors = libxml_use_internal_errors( true );
$xmlObject = simplexml_load_string( $XML );
if ( !$xmlObject ) {
//depends on https://gerrit.wikimedia.org/r/#/c/66365/
$xmlObject = new XmlTypeCheck($XML, null, false);
if ( ! $xmlObject->wellFormed ) {
wfDebugLog( "Math", "XML validation error:\n " . var_export( $XML, true ) . "\n" );
foreach ( libxml_get_errors() as $error ) {
wfDebugLog( "Math", "\t" . $error->message );
}
libxml_clear_errors();
} else {
$name = $xmlObject->getName();
$name = $xmlObject->getRootElement();
$name = str_replace('http://www.w3.org/1998/Math/MathML:', '', $name);
if ( $name == "math" or $name == "table" or $name == "div" ) {
$out = true;
} else {
wfDebugLog( "Math", "got wrong root element " . $name );
}
}
libxml_use_internal_errors( $prevInternalErrors );
return $out;
}