]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/StringUtils.php
MediaWiki 1.16.2
[autoinstallsdev/mediawiki.git] / includes / StringUtils.php
index c437b3c19e48a5d2b8341b303ee5802afdc22505..0be88df5ae35d35648705ffd165dc88cb3d6931e 100644 (file)
@@ -77,16 +77,20 @@ class StringUtils {
                        }
 
                        if ( $tokenType == 'start' ) {
-                               $inputPos = $tokenOffset + $tokenLength;
                                # Only move the start position if we haven't already found a start
                                # This means that START START END matches outer pair
                                if ( !$foundStart ) {
                                        # Found start
+                                       $inputPos = $tokenOffset + $tokenLength;
                                        # Write out the non-matching section
                                        $output .= substr( $subject, $outputPos, $tokenOffset - $outputPos );
                                        $outputPos = $tokenOffset;
                                        $contentPos = $inputPos;
                                        $foundStart = true;
+                               } else {
+                                       # Move the input position past the *first character* of START,
+                                       # to protect against missing END when it overlaps with START
+                                       $inputPos = $tokenOffset + 1;
                                }
                        } elseif ( $tokenType == 'end' ) {
                                if ( $foundStart ) {