fix for Bug #93 “tilde signatures inside nowiki tags sometimes get expanded (<include...
[lhc/web/wiklou.git] / includes / parser / Preprocessor_Hash.php
index 45af9ee..7f175e5 100644 (file)
@@ -24,10 +24,17 @@ class Preprocessor_Hash implements Preprocessor {
                $this->parser = $parser;
        }
 
+       /**
+        * @return PPFrame_Hash
+        */
        function newFrame() {
                return new PPFrame_Hash( $this );
        }
 
+       /**
+        * @param $args
+        * @return PPCustomFrame_Hash
+        */
        function newCustomFrame( $args ) {
                return new PPCustomFrame_Hash( $this, $args );
        }
@@ -137,6 +144,9 @@ class Preprocessor_Hash implements Preprocessor {
                        if ( strpos( $text, '<onlyinclude>' ) !== false && strpos( $text, '</onlyinclude>' ) !== false ) {
                                $enableOnlyinclude = true;
                        }
+               } else if ( $this->parser->ot['wiki'] ) {
+                       $ignoredTags = array( 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude', 'includeonly', '/includeonly' );
+                       $ignoredElements = array();
                } else {
                        $ignoredTags = array( 'noinclude', '/noinclude', 'onlyinclude', '/onlyinclude' );
                        $ignoredElements = array( 'includeonly' );
@@ -304,13 +314,11 @@ class Preprocessor_Hash implements Preprocessor {
 
                                                if ( $stack->top ) {
                                                        $part = $stack->top->getCurrentPart();
-                                                       if ( isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 ) {
-                                                               // Comments abutting, no change in visual end
-                                                               $part->commentEnd = $wsEnd;
-                                                       } else {
+                                                       if ( ! (isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) {
                                                                $part->visualEnd = $wsStart;
-                                                               $part->commentEnd = $endPos;
                                                        }
+                                                       // Else comments abutting, no change in visual end
+                                                       $part->commentEnd = $endPos;
                                                }
                                                $i = $endPos + 1;
                                                $inner = substr( $text, $startPos, $endPos - $startPos + 1 );
@@ -493,7 +501,7 @@ class Preprocessor_Hash 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 );
@@ -820,7 +828,21 @@ class PPDAccum_Hash {
  * @ingroup Parser
  */
 class PPFrame_Hash implements PPFrame {
-       var $preprocessor, $parser, $title;
+
+       /**
+        * @var Parser
+        */
+       var $parser;
+
+       /**
+        * @var Preprocessor
+        */
+       var $preprocessor;
+
+       /**
+        * @var Title
+        */
+       var $title;
        var $titleCache;
 
        /**
@@ -888,8 +910,7 @@ class PPFrame_Hash 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>';
                }
                if ( $expansionDepth > $this->parser->mOptions->getMaxPPExpandDepth() ) {
@@ -1018,7 +1039,7 @@ class PPFrame_Hash implements PPFrame {
                                                $serial = count( $this->parser->mHeadings ) - 1;
                                                $marker = "{$this->parser->mUniqPrefix}-h-$serial-" . Parser::MARKER_SUFFIX;
                                                $s = substr( $s, 0, $bits['level'] ) . $marker . substr( $s, $bits['level'] );
-                                               $this->parser->mStripState->general->setPair( $marker, '' );
+                                               $this->parser->mStripState->addGeneral( $marker, '' );
                                                $out .= $s;
                                        } else {
                                                # Expand in virtual stack
@@ -1197,6 +1218,8 @@ class PPFrame_Hash implements PPFrame {
 
        /**
         * Returns true if the infinite loop check is OK, false if a loop is detected
+        *
+        * @param $title Title
         */
        function loopCheck( $title ) {
                return !isset( $this->loopCheckHash[$title->getPrefixedDBkey()] );
@@ -1218,6 +1241,13 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
        var $numberedArgs, $namedArgs, $parent;
        var $numberedExpansionCache, $namedExpansionCache;
 
+       /**
+        * @param $preprocessor
+        * @param $parent
+        * @param $numberedArgs array
+        * @param $namedArgs array
+        * @param $title Title
+        */
        function __construct( $preprocessor, $parent = false, $numberedArgs = array(), $namedArgs = array(), $title = false ) {
                parent::__construct( $preprocessor );
 
@@ -1254,11 +1284,16 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
        }
        /**
         * Returns true if there are no arguments in this frame
+        *
+        * @return bool
         */
        function isEmpty() {
                return !count( $this->numberedArgs ) && !count( $this->namedArgs );
        }
 
+       /**
+        * @return array
+        */
        function getArguments() {
                $arguments = array();
                foreach ( array_merge(
@@ -1269,6 +1304,9 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
                return $arguments;
        }
 
+       /**
+        * @return array
+        */
        function getNumberedArguments() {
                $arguments = array();
                foreach ( array_keys($this->numberedArgs) as $key ) {
@@ -1277,6 +1315,9 @@ class PPTemplateFrame_Hash extends PPFrame_Hash {
                return $arguments;
        }
 
+       /**
+        * @return array
+        */
        function getNamedArguments() {
                $arguments = array();
                foreach ( array_keys($this->namedArgs) as $key ) {