diff options
author | Oliver Schramm <oliver.schramm97@gmail.com> | 2014-03-28 21:58:18 +0100 |
---|---|---|
committer | Oliver Schramm <oliver.schramm97@gmail.com> | 2014-03-28 22:28:14 +0100 |
commit | 02378e94e779bbd407ef86166884c00e32d152fc (patch) | |
tree | b554c42d37bf174335a09ff6f3129cdaaf9583d1 /phpBB/search.php | |
parent | 40ed3f677699f2d9801bb75168e84766c35722f4 (diff) | |
download | forums-02378e94e779bbd407ef86166884c00e32d152fc.tar forums-02378e94e779bbd407ef86166884c00e32d152fc.tar.gz forums-02378e94e779bbd407ef86166884c00e32d152fc.tar.bz2 forums-02378e94e779bbd407ef86166884c00e32d152fc.tar.xz forums-02378e94e779bbd407ef86166884c00e32d152fc.zip |
[ticket/10423] Remove * from search or highlight string
PHPBB3-10423
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 9 |
1 files changed, 5 insertions, 4 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('+', '-', '|', '(', ')', '"'), ' ', $keywords))); + $hilit = implode('|', explode(' ', preg_replace('#\s+#u', ' ', $hilit))); $u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit))); $u_show_results = '&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); |