Skip to content

Commit

Permalink
Fix escape logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-goe authored and ipf committed Sep 22, 2022
1 parent 4248d88 commit e7f7038
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Classes/Service/SolrServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ protected function queryComponentsForQueryParameters(array $queryParameters): ar
// Escape all arguments unless told not to do so.
if (!$fieldInfo['noescape']) {
$escapedQueryTerms = [];
if (is_array($queryTerms) && [] !== $queryTerms) {
if (is_array($queryTerms) && [] !== $queryTerms && count($queryTerms) > 1) {
foreach ($queryTerms as $key => $term) {
if ($fieldInfo['phrase']) {
$escapedQueryTerms[$key] = $this->query->getHelper()->escapePhrase($term);
Expand Down Expand Up @@ -1044,7 +1044,7 @@ protected function queryComponentsForQueryParameters(array $queryParameters): ar
$magicFieldPrefix .= '{!edismax}';
}

if (2 === $fieldInfo['noescape']) {
if (2 === (int) $fieldInfo['noescape']) {
$chars = explode(',', $fieldInfo['escapechar']);
foreach ($queryTerms as $key => $term) {
foreach ($chars as $char) {
Expand All @@ -1053,7 +1053,7 @@ protected function queryComponentsForQueryParameters(array $queryParameters): ar
}

$queryPart = $magicFieldPrefix.vsprintf($queryFormat, $queryTerms);
} elseif ($fieldInfo['noescape']) {
} elseif (1 === (int) $fieldInfo['noescape']) {
$queryPart = $magicFieldPrefix.vsprintf($queryFormat, $queryTerms);
} else {
$queryPart = $magicFieldPrefix.$this->query->getHelper()->escapePhrase(vsprintf($queryFormat, $queryTerms));
Expand Down

0 comments on commit e7f7038

Please sign in to comment.