r33488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33487‎ | r33488 | r33489 >
Date:15:38, 17 April 2008
Author:greg
Status:old
Tags:
Comment:
Escape forward slashes in search terms, otherwise PHP thinks the regex has ended and starts treating the rest of the characters in the string as PCRE modifiers.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SearchEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SearchEngine.php
@@ -571,6 +571,7 @@
572572 $lines = explode( "\n", $text );
573573
574574 $terms = implode( '|', $terms );
 575+ $terms = str_replace( '/', "\\/", $terms);
575576 $max = intval( $contextchars ) + 1;
576577 $pat1 = "/(.*)($terms)(.{0,$max})/i";
577578
Index: trunk/phase3/RELEASE-NOTES
@@ -190,6 +190,8 @@
191191 * (bug 13756) Don't show the form and navigation links of Special:Newpages if
192192 the page is included
193193 * When hiding things on WhatLinksHere, generated URLs should hide them too
 194+* Properly escape search terms with forward slashes so they appear highlighted
 195+ in search results.
194196
195197
196198 === API changes in 1.13 ===

Status & tagging log