Properly escape search terms in the context highlighter.

This commit is contained in:
Starbeamrainbowlabs 2015-11-14 17:02:57 +00:00
parent b539cb4107
commit 0e3a7f345a
3 changed files with 3 additions and 3 deletions

View File

@ -1957,7 +1957,7 @@ class search
foreach($qterms as $qterm)
{
// From http://stackoverflow.com/a/2483859/1460422
$context = preg_replace("/" . preg_quote($qterm) . "/i", "<strong>$0</strong>", $context);
$context = preg_replace("/" . preg_quote(str_replace("/", "\/", $qterm)) . "/i", "<strong>$0</strong>", $context);
}
return $context;

View File

@ -50,7 +50,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki. Note that this module, at the moment, just contains test code while I figure out how best to write a search engine.",
"id": "feature-search",
"lastupdate": 1447520172,
"lastupdate": 1447520515,
"optional": false
},
{

View File

@ -472,7 +472,7 @@ class search
foreach($qterms as $qterm)
{
// From http://stackoverflow.com/a/2483859/1460422
$context = preg_replace("/" . preg_quote($qterm) . "/i", "<strong>$0</strong>", $context);
$context = preg_replace("/" . preg_quote(str_replace("/", "\/", $qterm)) . "/i", "<strong>$0</strong>", $context);
}
return $context;