diff --git a/src/Utilities/Request.php b/src/Utilities/Request.php index fbbc6577..14957ec3 100644 --- a/src/Utilities/Request.php +++ b/src/Utilities/Request.php @@ -194,10 +194,10 @@ public function columnKeyword(int $index): string protected function prepareKeyword(float|array|int|string $keyword): string { if (is_array($keyword)) { - return implode(' ', $keyword); + $keyword = implode(' ', $keyword); } - return (string) $keyword; + return e((string) $keyword); } /** diff --git a/tests/Integration/QueryDataTableTest.php b/tests/Integration/QueryDataTableTest.php index e3e20ccb..588d03dd 100644 --- a/tests/Integration/QueryDataTableTest.php +++ b/tests/Integration/QueryDataTableTest.php @@ -80,6 +80,31 @@ public function it_can_perform_global_search() ]); } + /** @test */ + public function it_can_perform_global_search_with_html_string() + { + User::create([ + 'name' => e('Record & 21'), + 'email' => 'Email-21@example.com', + ]); + + $this->assertEquals('Record & 21', User::find(21)->name); + + $crawler = $this->call('GET', '/query/users', [ + 'columns' => [ + ['data' => 'name', 'name' => 'name', 'searchable' => 'true', 'orderable' => 'true'], + ['data' => 'email', 'name' => 'email', 'searchable' => 'true', 'orderable' => 'true'], + ], + 'search' => ['value' => 'Record & 21'], + ]); + + $crawler->assertJson([ + 'draw' => 0, + 'recordsTotal' => 21, + 'recordsFiltered' => 1, + ]); + } + /** @test */ public function it_can_skip_total_records_count_query() {