aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/search.php
diff options
context:
space:
mode:
authorOliver Schramm <oliver.schramm97@gmail.com>2014-04-13 21:15:14 +0200
committerOliver Schramm <oliver.schramm97@gmail.com>2014-04-13 21:15:14 +0200
commitface175471b5064117ca57ece53a3403e51e20ba (patch)
treea0954756c4e4c1d56f96e9a0cb3ee52e5ae5a4ce /phpBB/search.php
parent02378e94e779bbd407ef86166884c00e32d152fc (diff)
downloadforums-face175471b5064117ca57ece53a3403e51e20ba.tar
forums-face175471b5064117ca57ece53a3403e51e20ba.tar.gz
forums-face175471b5064117ca57ece53a3403e51e20ba.tar.bz2
forums-face175471b5064117ca57ece53a3403e51e20ba.tar.xz
forums-face175471b5064117ca57ece53a3403e51e20ba.zip
[ticket/10423] Move code into a function and add tests for it
PHPBB3-10423
Diffstat (limited to 'phpBB/search.php')
-rw-r--r--phpBB/search.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/phpBB/search.php b/phpBB/search.php
index 43eb42514e..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
- // 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)));
+ // 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,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$hilit_array = array_filter(explode('|', $hilit), 'strlen');
foreach ($hilit_array as $key => $value)
{
- $hilit_array[$key] = preg_replace('#\s+#u', ' ', trim(preg_replace('#(?<=^|\s)\*(?=\s|$)#', '', $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]);
}