From fd385525f8f0ee4303cc77714c3d4207301f44a2 Mon Sep 17 00:00:00 2001 From: Ambroise Maupate Date: Thu, 23 Mar 2023 18:09:44 +0100 Subject: [PATCH] fix: Fixed AjaxNodesExplorerController search params strict typing. --- .../AjaxNodesExplorerController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php b/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php index 5842e159..2ca632f2 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php @@ -173,14 +173,25 @@ protected function getSolrSearchResults( ): array { $this->nodeSourceSearchHandler->boostByUpdateDate(); $currentPage = $request->get('page', 1); + $searchQuery = $request->get('search'); + + if (!\is_string($searchQuery)) { + throw new InvalidParameterException('Search query must be a string'); + } + if (empty($searchQuery)) { + throw new InvalidParameterException('Search query cannot be empty'); + } + if ($currentPage < 1) { + throw new InvalidParameterException('Current page must be greater than 0'); + } $results = $this->nodeSourceSearchHandler->search( - $request->get('search'), + $searchQuery, $arrayFilter, $this->getItemPerPage(), true, 10000000, - $currentPage + (int) $currentPage ); $pageCount = ceil($results->getResultCount() / $this->getItemPerPage()); $nodesArray = $this->normalizeNodes($results);