r103673 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103672‎ | r103673 | r103674 >
Date:13:50, 19 November 2011
Author:catrope
Status:ok
Tags:
Comment:
preg_quote() some regex input in DoubleWiki
Modified paths:
  • /trunk/extensions/DoubleWiki/DoubleWiki_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DoubleWiki/DoubleWiki_body.php
@@ -26,7 +26,7 @@
2727 * Read the list of matched phrases and add tags to the html output.
2828 */
2929 function addMatchingTags ( &$text, $lang ) {
30 - $pattern = "/<div id=\"align-$lang\" style=\"display:none;\">\n*<pre>(.*?)<\/pre>\n*<\/div>/is";
 30+ $pattern = "/<div id=\"align-" . preg_quote( $lang, '/' ) . "\" style=\"display:none;\">\n*<pre>(.*?)<\/pre>\n*<\/div>/is";
3131 $m = array();
3232 if ( ! preg_match( $pattern, $text, $m ) ) {
3333 return;
@@ -36,7 +36,7 @@
3737 $items = array();
3838 preg_match_all( $line_pattern, $m[1], $items, PREG_SET_ORDER );
3939 foreach ( $items as $n => $i ) {
40 - $text = str_replace( $i[1], "<span id=\"dw-$n\" title=\"{$i[2]}\"/>" . $i[1], $text );
 40+ $text = str_replace( $i[1], "<span id=\"dw-" . preg_quote( $n, '/' ) . "\" title=\"{$i[2]}\"/>" . $i[1], $text );
4141 }
4242 }
4343

Follow-up revisions

RevisionCommit summaryAuthorDate
r1036741.18wmf1: MFT r103673catrope13:51, 19 November 2011

Status & tagging log