Quote delimiter in target text when using regular expressions

bug: T354498
Change-Id: I0bafbaa4cfb55e2d65712a747a2622b159417dea
This commit is contained in:
Mark A. Hershberger 2024-01-07 19:09:16 -05:00
parent 475ad71b4c
commit e9a086c4ee
No known key found for this signature in database
GPG key ID: C5E6B11787B8FA01

View file

@ -914,7 +914,8 @@ class SpecialReplaceText extends SpecialPage {
// Get all indexes
if ( $use_regex ) {
preg_match_all( "/$target/Uu", $text, $matches, PREG_OFFSET_CAPTURE );
$targetq = str_replace( "/", "\\/", $target );
preg_match_all( "/$targetq/Uu", $text, $matches, PREG_OFFSET_CAPTURE );
} else {
$targetq = preg_quote( $target, '/' );
preg_match_all( "/$targetq/", $text, $matches, PREG_OFFSET_CAPTURE );