aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-12-03 21:00:42 -0500
committercash <cash.costello@gmail.com>2011-12-03 21:03:42 -0500
commitf1c8a2dadee9a31bf941b92eb3f4030b4f89d191 (patch)
tree6e6b462be53709740ebf733d04266f6cd50d73b9 /mod
parent8e7dfcc5146f1cb22e684a9cdb635bbac184d6a1 (diff)
downloadelgg-f1c8a2dadee9a31bf941b92eb3f4030b4f89d191.tar.gz
elgg-f1c8a2dadee9a31bf941b92eb3f4030b4f89d191.tar.bz2
Fixes #4046 checking offset compared to string length
Diffstat (limited to 'mod')
-rw-r--r--mod/search/start.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/mod/search/start.php b/mod/search/start.php
index 73a96dc0a..bb8531e9c 100644
--- a/mod/search/start.php
+++ b/mod/search/start.php
@@ -107,6 +107,7 @@ function search_get_highlighted_relevant_substrings($haystack, $query, $min_matc
$word = elgg_strtolower($word);
$count = elgg_substr_count($haystack_lc, $word);
$word_len = elgg_strlen($word);
+ $haystack_len = elgg_strlen($haystack_lc);
// find the start positions for the words
if ($count > 1) {
@@ -117,6 +118,10 @@ function search_get_highlighted_relevant_substrings($haystack, $query, $min_matc
$stop = $pos + $word_len + $min_match_context;
$lengths[] = $stop - $start;
$offset += $pos + $word_len;
+
+ if ($offset >= $haystack_len) {
+ break;
+ }
}
} else {
$pos = elgg_strpos($haystack_lc, $word);