mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ReplaceText
synced 2024-11-14 10:34:39 +00:00
Move setting of targetStr to outside of loop
Change-Id: Ibdcd83ce5d4368bf06f2d57261985a71f7b666ab
This commit is contained in:
parent
5190b2cd39
commit
8c890f5ce9
|
@ -872,6 +872,13 @@ class SpecialReplaceText extends SpecialPage {
|
|||
$cuts[] = [ $index, $len ];
|
||||
}
|
||||
|
||||
if ( $use_regex ) {
|
||||
$targetStr = "/$target/Uu";
|
||||
} else {
|
||||
$targetq = preg_quote( $this->convertWhiteSpaceToHTML( $target ), '/' );
|
||||
$targetStr = "/$targetq/i";
|
||||
}
|
||||
|
||||
$context = '';
|
||||
foreach ( $cuts as $_ ) {
|
||||
[ $index, $len, ] = $_;
|
||||
|
@ -883,12 +890,6 @@ class SpecialReplaceText extends SpecialPage {
|
|||
|
||||
$context .= $this->convertWhiteSpaceToHTML( $contextBefore );
|
||||
$snippet = $this->convertWhiteSpaceToHTML( substr( $text, $index, $len ) );
|
||||
if ( $use_regex ) {
|
||||
$targetStr = "/$target/Uu";
|
||||
} else {
|
||||
$targetq = preg_quote( $this->convertWhiteSpaceToHTML( $target ), '/' );
|
||||
$targetStr = "/$targetq/i";
|
||||
}
|
||||
$context .= preg_replace( $targetStr, '<span class="ext-replacetext-searchmatch">\0</span>', $snippet );
|
||||
|
||||
$context .= $this->convertWhiteSpaceToHTML( $contextAfter );
|
||||
|
|
Loading…
Reference in a new issue