r61569 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61568‎ | r61569 | r61570 >
Date:11:25, 27 January 2010
Author:platonides
Status:ok
Tags:
Comment:
Follow-up r61154. Use StringUtils::escapeRegexReplacement() instead of manually replacing the characters.
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -710,7 +710,7 @@
711711
712712 // Use regex to allow limit and handle UTF-8 correctly.
713713 $inReplaceFrom = preg_quote( $inReplaceFrom, '/' );
714 - $inReplaceTo = strtr( $inReplaceTo, array("\\" => "\\\\", '$'=>"\\$" ) );
 714+ $inReplaceTo = StringUtils::escapeRegexReplacement( $inReplaceTo );
715715
716716 $result = preg_replace( '/' . $inReplaceFrom . '/u',
717717 $inReplaceTo, $inStr, $limit);

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61154Follow up r61149. Using preg_quote on $inReplaceTo replaces too much. However...platonides23:52, 16 January 2010

Status & tagging log