Skip to content

Commit 673b586

Browse files
authored
Add trim to search terms in order to prevent accidental user input from failing (#1872)
1 parent fd0cf10 commit 673b586

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/DataSource/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function filterContains(): Builder
140140
return $this;
141141
}
142142

143-
$search = strtolower(htmlspecialchars($this->component->search, ENT_QUOTES | ENT_HTML5, 'UTF-8'));
143+
$search = trim(strtolower(htmlspecialchars($this->component->search, ENT_QUOTES | ENT_HTML5, 'UTF-8')));
144144
$hasRelationSearch = count($this->component->relationSearch()) && $this->query instanceof EloquentBuilder;
145145

146146
$this->query = $this->query->where(

src/DataSource/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected static function paginator(BaseCollection $items, int $total, int $perP
6868

6969
public function search(): BaseCollection
7070
{
71-
$searchTerm = strtolower($this->powerGridComponent->search);
71+
$searchTerm = trim(strtolower($this->powerGridComponent->search));
7272

7373
if (empty($searchTerm)) {
7474
return $this->collection;

0 commit comments

Comments
 (0)