TheDJ has submitted this change and it was merged. Change subject: Replace SimpleXml by Mediawiki library ......................................................................
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 --- M MathLaTeXML.php 1 file changed, 5 insertions(+), 9 deletions(-) Approvals: TheDJ: Looks good to me, approved jenkins-bot: Verified diff --git a/MathLaTeXML.php b/MathLaTeXML.php index 42e25d2..8fd2c05 100644 --- a/MathLaTeXML.php +++ b/MathLaTeXML.php @@ -204,23 +204,19 @@ */ 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; } -- To view, visit https://gerrit.wikimedia.org/r/67563 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iafbd820f7130c8eb8d4f19824632b4ac89f214a9 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: master Gerrit-Owner: Physikerwelt <[email protected]> Gerrit-Reviewer: Cjucovschi <[email protected]> Gerrit-Reviewer: Hoo man <[email protected]> Gerrit-Reviewer: Mattflaschen <[email protected]> Gerrit-Reviewer: Ori.livneh <[email protected]> Gerrit-Reviewer: Physikerwelt <[email protected]> Gerrit-Reviewer: TheDJ <[email protected]> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
