X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/2acc6b86c3191c408dc027d5164c397bea97d37b..d274a1744ec81daf286c6175b0dbde867ca1b545:/includes/StringUtils.php diff --git a/includes/StringUtils.php b/includes/StringUtils.php index c437b3c1..0be88df5 100644 --- a/includes/StringUtils.php +++ b/includes/StringUtils.php @@ -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 ) {