revert r111028 (attempt to fix bug 34254)
[lhc/web/wiklou.git] / includes / parser / Preprocessor_DOM.php
index 48c2345..54079ac 100644 (file)
@@ -81,7 +81,7 @@ class Preprocessor_DOM implements Preprocessor {
         */
        function memCheck() {
                if ( $this->memoryLimit === false ) {
-                       return;
+                       return true;
                }
                $usage = memory_get_usage();
                if ( $usage > $this->memoryLimit * 0.9 ) {
@@ -155,7 +155,8 @@ class Preprocessor_DOM implements Preprocessor {
                if ( !$result ) {
                        // Try running the XML through UtfNormal to get rid of invalid characters
                        $xml = UtfNormal::cleanUp( $xml );
-                       $result = $dom->loadXML( $xml );
+                       // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
+                       $result = $dom->loadXML( $xml, 1 << 19 );
                        if ( !$result ) {
                                throw new MWException( __METHOD__.' generated invalid XML' );
                        }
@@ -542,7 +543,7 @@ class Preprocessor_DOM implements Preprocessor {
                                                'open' => $curChar,
                                                'close' => $rule['end'],
                                                'count' => $count,
-                                               'lineStart' => ($i == 0 || $text[$i-1] == "\n"),
+                                               'lineStart' => ($i > 0 && $text[$i-1] == "\n"),
                                        );
 
                                        $stack->push( $piece );
@@ -956,8 +957,7 @@ class PPFrame_DOM implements PPFrame {
                        return $root;
                }
 
-               if ( ++$this->parser->mPPNodeCount > $this->parser->mOptions->getMaxPPNodeCount() )
-               {
+               if ( ++$this->parser->mPPNodeCount > $this->parser->mOptions->getMaxPPNodeCount() ) {
                        return '<span class="error">Node-count limit exceeded</span>';
                }
 
@@ -1250,6 +1250,7 @@ class PPFrame_DOM implements PPFrame {
 
        /**
         * Virtual implode with brackets
+        * @return array
         */
        function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) {
                $args = array_slice( func_get_args(), 3 );
@@ -1339,6 +1340,15 @@ class PPFrame_DOM implements PPFrame {
        function isTemplate() {
                return false;
        }
+
+       /**
+        * Get a title of frame
+        *
+        * @return Title
+        */
+       function getTitle() {
+               return $this->title;
+       }
 }
 
 /**
@@ -1665,6 +1675,7 @@ class PPNode_DOM implements PPNode {
 
        /**
         * Split a <h> node
+        * @return array
         */
        function splitHeading() {
                if ( $this->getName() !== 'h' ) {