From 377f79b5b8c596be01f58dd2fb6926fdc9107fef Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Thu, 17 Apr 2008 15:38:26 +0000 Subject: [PATCH] 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. --- RELEASE-NOTES | 2 ++ includes/SearchEngine.php | 1 + 2 files changed, 3 insertions(+) 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"; -- 2.20.1