aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/search.php9
-rw-r--r--phpBB/viewtopic.php3
2 files changed, 7 insertions, 5 deletions
diff --git a/phpBB/search.php b/phpBB/search.php
index 0f13dbbfa0..43eb42514e 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -574,9 +574,9 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
// define some vars for urls
- $hilit = implode('|', explode(' ', preg_replace('#\s+#u', ' ', str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords))));
- // Do not allow *only* wildcard being used for hilight
- $hilit = (strspn($hilit, '*') === strlen($hilit)) ? '' : $hilit;
+ // A single wildcard will destroy the search query
+ $hilit = trim(preg_replace('#(?<=^|\s)\*(?=\s|$)#', '', str_replace(array('+', '-', '|', '(', ')', '&quot;'), ' ', $keywords)));
+ $hilit = implode('|', explode(' ', preg_replace('#\s+#u', ' ', $hilit)));
$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));
$u_show_results = '&amp;sr=' . $show_results;
@@ -840,7 +840,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$hilit_array = array_filter(explode('|', $hilit), 'strlen');
foreach ($hilit_array as $key => $value)
{
- $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($value, '#'));
+ $hilit_array[$key] = preg_replace('#\s+#u', ' ', trim(preg_replace('#(?<=^|\s)\*(?=\s|$)#', '', $value)));
+ $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#'));
$hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]);
}
$hilit = implode('|', $hilit_array);
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index e08d6e1ef5..4c9302dbbe 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -475,9 +475,10 @@ if ($hilit_words)
{
if (trim($word))
{
+ $word = preg_replace('#\s+#u', ' ', trim(preg_replace('#(?<=^|\s)\*(?=\s|$)#', '', $word)));
$word = str_replace('\*', '\w+?', preg_quote($word, '#'));
$word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
- $highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
+ $highlight_match .= (($highlight_match != '' && $word != '') ? '|' : '') . $word;
}
}