From ff141daa808edcdaa77e93cf799eef04b197d954 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 9 Dec 2007 08:13:32 +0000 Subject: [PATCH] * Hacky fix for invalid character problem * Fixed bug in Parser::splitBraceNode --- includes/Parser.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 2899a11c7a..b05d26a5f7 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2985,8 +2985,16 @@ class Parser wfProfileOut( __METHOD__.'-makexml' ); wfProfileIn( __METHOD__.'-loadXML' ); $dom = new DOMDocument; - if ( !$dom->loadXML( $topAccum ) ) { - throw new MWException( __METHOD__.' generated invalid XML' ); + wfSuppressWarnings(); + $result = $dom->loadXML( $topAccum ); + wfRestoreWarnings(); + if ( !$result ) { + // Try running the XML through UtfNormal to get rid of invalid characters + $topAccum = UtfNormal::cleanUp( $topAccum ); + $result = $dom->loadXML( $topAccum ); + if ( !$result ) { + throw new MWException( __METHOD__.' generated invalid XML' ); + } } wfProfileOut( __METHOD__.'-loadXML' ); wfProfileOut( __METHOD__ ); @@ -5423,7 +5431,7 @@ class PPFrame { * DOMNode name, string index and DOMNode value */ function splitBraceNode( $node ) { - $xpath = new DOMXPath( $arg->ownerDocument ); + $xpath = new DOMXPath( $node->ownerDocument ); $names = $xpath->query( 'name', $node ); $values = $xpath->query( 'value', $node ); if ( !$names->length || !$values->length ) { -- 2.20.1