From: Tim Starling Date: Sun, 9 Dec 2007 08:13:32 +0000 (+0000) Subject: * Hacky fix for invalid character problem X-Git-Tag: 1.31.0-rc.0~50484 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=ff141daa808edcdaa77e93cf799eef04b197d954;p=lhc%2Fweb%2Fwiklou.git * Hacky fix for invalid character problem * Fixed bug in Parser::splitBraceNode --- 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 ) {