Skip to content

Commit 0881668

Browse files
committed
Trim search phrases
1 parent 40d7238 commit 0881668

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/WebApp/Component/SearchFilterBar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct($parent) {
1616
}
1717

1818
public static function getSearchPhrase() {
19-
return Request::getRequest()->getParam('search');
19+
return trim(Request::getRequest()->getParam('search'));
2020
}
2121

2222
public static function getFilters() {

src/WebApp/DataModel/UserDAO.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ public function getSearchClause($s) {
8585
if (!\TgUtils\Utils::isEmpty($s)) {
8686
$where = '';
8787
foreach (explode(' ', $s) AS $part) {
88-
$value = $this->database->escape(strtolower($part));
89-
$where .= ' OR (LOWER(`name`) LIKE \'%'.$value.'%\') OR (LOWER(`email`) LIKE \'%'.$value.'%\')';
88+
$value = trim($part);
89+
if (strlen($value) > 0) {
90+
$value = $this->database->escape(strtolower($value));
91+
$where .= ' OR (LOWER(`name`) LIKE \'%'.$value.'%\') OR (LOWER(`email`) LIKE \'%'.$value.'%\')';
92+
}
9093
}
9194
$rc[] = substr($where, 4);
9295
}

0 commit comments

Comments
 (0)