mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/9760] Remove unrestricted wildcards from search terms.
Wildcards without any further result restrictions will cause phpBB to search for everything, potentially allowing a DoS attack against the DB server by any user who can use the search system. PHPBB3-9760
This commit is contained in:
parent
4ac5d5e352
commit
76348ce43f
1 changed files with 12 additions and 1 deletions
|
@ -83,7 +83,9 @@ class fulltext_native extends search_backend
|
|||
{
|
||||
global $db, $user, $config;
|
||||
|
||||
$keywords = trim($this->cleanup($keywords, '+-|()*'));
|
||||
$tokens = '+-|()*';
|
||||
|
||||
$keywords = trim($this->cleanup($keywords, $tokens));
|
||||
|
||||
// allow word|word|word without brackets
|
||||
if ((strpos($keywords, ' ') === false) && (strpos($keywords, '|') !== false) && (strpos($keywords, '(') === false))
|
||||
|
@ -114,6 +116,15 @@ class fulltext_native extends search_backend
|
|||
case ' ':
|
||||
$keywords[$i] = '|';
|
||||
break;
|
||||
case '*':
|
||||
if ($i === 0 || ($keywords[$i - 1] !== '*' && strcspn($keywords[$i - 1], $tokens) === 0))
|
||||
{
|
||||
if ($i === $n - 1 || ($keywords[$i + 1] !== '*' && strcspn($keywords[$i + 1], $tokens) === 0))
|
||||
{
|
||||
$keywords = substr($keywords, 0, $i) . substr($keywords, $i + 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue