$out is needed here
[lhc/web/wiklou.git] / includes / Preprocessor_DOM.php
index 0e2e9a1..526bd71 100644 (file)
@@ -267,6 +267,7 @@ class Preprocessor_DOM implements Preprocessor {
                                        continue;
                                }
                                $name = $matches[1];
+                               $lowerName = strtolower( $name );
                                $attrStart = $i + strlen( $name ) + 1;
 
                                // Find end of tag
@@ -281,7 +282,7 @@ class Preprocessor_DOM implements Preprocessor {
                                }
 
                                // Handle ignored tags
-                               if ( in_array( $name, $ignoredTags ) ) {
+                               if ( in_array( $lowerName, $ignoredTags ) ) {
                                        $accum .= '<ignore>' . htmlspecialchars( substr( $text, $i, $tagEndPos - $i + 1 ) ) . '</ignore>';
                                        $i = $tagEndPos + 1;
                                        continue;
@@ -308,7 +309,7 @@ class Preprocessor_DOM implements Preprocessor {
                                        }
                                }
                                // <includeonly> and <noinclude> just become <ignore> tags
-                               if ( in_array( $name, $ignoredElements ) ) {
+                               if ( in_array( $lowerName, $ignoredElements ) ) {
                                        $accum .= '<ignore>' . htmlspecialchars( substr( $text, $tagStartPos, $i - $tagStartPos ) ) 
                                                . '</ignore>';
                                        continue;
@@ -810,6 +811,7 @@ class PPFrame_DOM implements PPFrame {
        }
 
        function expand( $root, $flags = 0 ) {
+               static $depth = 0;
                if ( is_string( $root ) ) {
                        return $root;
                }
@@ -819,6 +821,11 @@ class PPFrame_DOM implements PPFrame {
                        return '<span class="error">Node-count limit exceeded</span>';
                }
 
+               if ( $depth > $this->parser->mOptions->mMaxPPExpandDepth ) {
+                       return '<span class="error">Expansion depth limit exceeded</span>';
+               }
+               ++$depth;
+
                if ( $root instanceof PPNode_DOM ) {
                        $root = $root->node;
                }
@@ -972,7 +979,7 @@ class PPFrame_DOM implements PPFrame {
                                                $titleText = $this->title->getPrefixedDBkey();
                                                $this->parser->mHeadings[] = array( $titleText, $headingIndex );
                                                $serial = count( $this->parser->mHeadings ) - 1;
-                                               $marker = "{$this->parser->mUniqPrefix}-h-$serial-{$this->parser->mMarkerSuffix}";
+                                               $marker = "{$this->parser->mUniqPrefix}-h-$serial-" . Parser::MARKER_SUFFIX;
                                                $count = $contextNode->getAttribute( 'level' );
                                                $s = substr( $s, 0, $count ) . $marker . substr( $s, $count );
                                                $this->parser->mStripState->general->setPair( $marker, '' );
@@ -1005,6 +1012,7 @@ class PPFrame_DOM implements PPFrame {
                                }
                        }
                }
+               --$depth;
                return $outStack[0];
        }