summaryrefslogtreecommitdiff
path: root/inc/fulltext.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/fulltext.php')
-rw-r--r--inc/fulltext.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php
index e90205e9c..7dae183c8 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -313,7 +313,7 @@ function ft_snippet($id,$highlight){
$len = utf8_strlen($text);
// build a regexp from the phrases to highlight
- $re1 = '('.join('|',array_map('preg_quote_cb',array_filter((array) $highlight))).')';
+ $re1 = '('.join('|',array_map('_ft_snippet_re_preprocess', array_map('preg_quote_cb',array_filter((array) $highlight)))).')';
$re2 = "$re1.{0,75}(?!\\1)$re1";
$re3 = "$re1.{0,45}(?!\\1)$re1.{0,45}(?!\\1)(?!\\2)$re1";
@@ -387,6 +387,13 @@ function ft_snippet($id,$highlight){
}
/**
+ * Wraps a search term in regex boundary checks.
+ */
+function _ft_snippet_re_preprocess($term) {
+ return '\b'.$term.'\b';
+}
+
+/**
* Combine found documents and sum up their scores
*
* This function is used to combine searched words with a logical