Skip to content

Commit 2afe956

Browse files
committed
BUGFIX: Fix missing escape of [ character
Also rename the "Sanitation" utility to "SearchTerm" as suggested in previous review
1 parent b068148 commit 2afe956

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

Classes/Controller/SuggestController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder;
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
1616
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception\QueryBuildingException;
17-
use Flowpack\SearchPlugin\Utility\Sanitation;
17+
use Flowpack\SearchPlugin\Utility\SearchTerm;
1818
use Neos\Cache\Frontend\VariableFrontend;
1919
use Neos\Flow\Annotations as Flow;
2020
use Neos\Flow\Mvc\Controller\ActionController;
@@ -116,7 +116,7 @@ protected function buildRequestForTerm(string $term, string $contextNodeIdentifi
116116

117117
// The suggest function only works well with one word
118118
// special search characters are escaped
119-
$suggestTerm = Sanitation::sanitizeSearchInput(explode(' ', $term)[0]);
119+
$suggestTerm = SearchTerm::sanitizeSearchInput(explode(' ', $term)[0]);
120120

121121
if (!$this->elasticSearchQueryTemplateCache->has($cacheKey)) {
122122
$contentContext = $this->createContentContext('live', $dimensionCombination ? json_decode($dimensionCombination, true) : []);

Classes/EelHelper/SuggestionIndexHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
use Flowpack\SearchPlugin\Exception;
17-
use Flowpack\SearchPlugin\Utility\Sanitation;
17+
use Flowpack\SearchPlugin\Utility\SearchTerm;
1818
use Neos\Eel\ProtectedContextAwareInterface;
1919
use Neos\Flow\Annotations as Flow;
2020

@@ -48,7 +48,7 @@ protected function prepareInput($input): ?array
4848
{
4949
$process = static function (?string $input) {
5050
$input = preg_replace("/\r|\n/", '', $input);
51-
return array_values(array_filter(explode(' ', Sanitation::sanitizeSearchInput(strip_tags($input)))));
51+
return array_values(array_filter(explode(' ', SearchTerm::sanitizeSearchInput(strip_tags($input)))));
5252
};
5353

5454
if (\is_string($input)) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
* source code.
1414
*/
1515

16-
class Sanitation
16+
class SearchTerm
1717
{
1818

1919
public static function sanitizeSearchInput(string $input): string
2020
{
21-
return str_replace(['=', '>', '<', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\', '/'], ['', '', '', '(', '\)', '\{', '\}', '[', '\]', '\^', '\"', '\~', '\*', '\?', '\:', '\\\\', '\/'], $input);
21+
return str_replace(['=', '>', '<', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\', '/'], ['', '', '', '(', '\)', '\{', '\}', '\[', '\]', '\^', '\"', '\~', '\*', '\?', '\:', '\\\\', '\/'], $input);
2222
}
2323

2424
}

0 commit comments

Comments
 (0)