From c166e49bca406780464c55601ebeacefd095633d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 22 Feb 2010 07:02:12 +0000 Subject: [PATCH] Fixes for r62505: * In MagicWordArray::matchStartAndRemove(), fixed the case where the length of localised synonym is not precisely the length of the magic word ID plus one * Fixed the case where matchStartAndRemove() removes the entire string, send empty string not false * Fix brace style --- includes/MagicWord.php | 13 ++++++++----- includes/parser/Parser.php | 3 +-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/MagicWord.php b/includes/MagicWord.php index ecbdf81699..d741832f61 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -719,11 +719,14 @@ class MagicWordArray { if ( $regex === '' ) { continue; } - preg_match( $regex, $text, $match ); - if ( $match ) { - list( $found, $param ) = $this->parseMatch( $match ); - $text = substr( $text, strlen( $found ) + 1 ); - return $found; + if ( preg_match( $regex, $text, $m ) ) { + list( $id, $param ) = $this->parseMatch( $m ); + if ( strlen( $m[0] ) >= strlen( $text ) ) { + $text = ''; + } else { + $text = substr( $text, strlen( $m[0] ) ); + } + return $id; } } return false; diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index aa901322c0..06d4ac51a7 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2793,8 +2793,7 @@ class Parser # Possibilities for substMatch: "subst", "safesubst" or FALSE # Decide whether to expand template or keep wikitext as-is. - if ( $this->ot['wiki'] ) - { + if ( $this->ot['wiki'] ) { if ( $substMatch === false ) { $literal = true; # literal when in PST with no prefix } else { -- 2.20.1