From: Greg Sabino Mullane Date: Thu, 17 Apr 2008 15:38:26 +0000 (+0000) Subject: Escape forward slashes in search terms, otherwise PHP thinks the regex has ended... X-Git-Tag: 1.31.0-rc.0~48238 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=377f79b5b8c596be01f58dd2fb6926fdc9107fef;p=lhc%2Fweb%2Fwiklou.git 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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6ddf2bd5e9..33d9d0c5f7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -190,6 +190,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13756) Don't show the form and navigation links of Special:Newpages if the page is included * When hiding things on WhatLinksHere, generated URLs should hide them too +* Properly escape search terms with forward slashes so they appear highlighted + in search results. === API changes in 1.13 === diff --git a/includes/SearchEngine.php b/includes/SearchEngine.php index d802a7fa6e..864be9d7a9 100644 --- a/includes/SearchEngine.php +++ b/includes/SearchEngine.php @@ -571,6 +571,7 @@ class SearchResult { $lines = explode( "\n", $text ); $terms = implode( '|', $terms ); + $terms = str_replace( '/', "\\/", $terms); $max = intval( $contextchars ) + 1; $pat1 = "/(.*)($terms)(.{0,$max})/i";