aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/search.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-15 23:23:26 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-15 23:23:26 +0200
commit675cef9c2e9ea571606415fb3228b5f2c73769d9 (patch)
tree4e47ae4209af12763265d69fddf90ad8b93ed021 /phpBB/search.php
parente64c2326bdf36ac071f07881d4ca5aba202e6249 (diff)
parentf3cd7f73e1ed3acbf1a319331e2f99ea27d5fe2d (diff)
downloadforums-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.php9
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('+', '-', '|', '(', ')', '&quot;'), ' ', $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('+', '-', '|', '(', ')', '&quot;'), ' ', $keywords));
+ $hilit = str_replace(' ', '|', $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] = 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);