From: Tim Starling Date: Mon, 22 Feb 2010 07:02:12 +0000 (+0000) Subject: Fixes for r62505: X-Git-Tag: 1.31.0-rc.0~37653 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/supprimer.php?a=commitdiff_plain;h=c166e49bca406780464c55601ebeacefd095633d;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 {