diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2014-04-15 23:23:26 +0200 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2014-04-15 23:23:26 +0200 |
| commit | 675cef9c2e9ea571606415fb3228b5f2c73769d9 (patch) | |
| tree | 4e47ae4209af12763265d69fddf90ad8b93ed021 /phpBB/search.php | |
| parent | e64c2326bdf36ac071f07881d4ca5aba202e6249 (diff) | |
| parent | f3cd7f73e1ed3acbf1a319331e2f99ea27d5fe2d (diff) | |
| download | forums-675cef9c2e9ea571606415fb3228b5f2c73769d9.tar forums-675cef9c2e9ea571606415fb3228b5f2c73769d9.tar.gz forums-675cef9c2e9ea571606415fb3228b5f2c73769d9.tar.bz2 forums-675cef9c2e9ea571606415fb3228b5f2c73769d9.tar.xz forums-675cef9c2e9ea571606415fb3228b5f2c73769d9.zip | |
Merge pull request #2195 from Elsensee/ticket/10423
[ticket/10423] Remove * from search or highlight string
* Elsensee/ticket/10423:
[ticket/10423] Replace foreach with function in viewtopic.php
[ticket/10423] Remove unnecessary include in test
[ticket/10423] Match multiple wildcards
[ticket/10423] Move code into a function and add tests for it
[ticket/10423] Remove * from search or highlight string
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..d0d86fac17 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 make the search results look ugly + $hilit = phpbb_clean_search_string(str_replace(array('+', '-', '|', '(', ')', '"'), ' ', $keywords)); + $hilit = str_replace(' ', '|', $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] = phpbb_clean_search_string($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); |
