From 1c5dcbe363a200c0fb3d2e2401820a1c46eef3bb Mon Sep 17 00:00:00 2001 From: Ruslan-Aleev Date: Mon, 31 Aug 2020 20:52:24 +0300 Subject: [PATCH 1/3] Removed the mistaken negation --- .../simplesearch/model/simplesearch/simplesearch.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/simplesearch/model/simplesearch/simplesearch.class.php b/core/components/simplesearch/model/simplesearch/simplesearch.class.php index 7e63fc9..b756962 100644 --- a/core/components/simplesearch/model/simplesearch/simplesearch.class.php +++ b/core/components/simplesearch/model/simplesearch/simplesearch.class.php @@ -152,7 +152,7 @@ public function parseSearchString($str = '') { $reserved = array('AND', 'OR', 'IN', 'NOT'); foreach ($this->searchArray as $key => $term) { $this->searchArray[$key] = strip_tags($term); - if (strlen($term) < $minChars && !in_array($term, $reserved)) { + if (strlen($term) < $minChars && in_array($term, $reserved)) { unset($this->searchArray[$key]); } } From 13161c3c90f6058f5ec157c20346eda4dec219f8 Mon Sep 17 00:00:00 2001 From: Ruslan-Aleev Date: Mon, 31 Aug 2020 20:56:11 +0300 Subject: [PATCH 2/3] Added accounting for encoding in calculating length --- .../simplesearch/model/simplesearch/simplesearch.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/simplesearch/model/simplesearch/simplesearch.class.php b/core/components/simplesearch/model/simplesearch/simplesearch.class.php index b756962..fe6a498 100644 --- a/core/components/simplesearch/model/simplesearch/simplesearch.class.php +++ b/core/components/simplesearch/model/simplesearch/simplesearch.class.php @@ -152,7 +152,7 @@ public function parseSearchString($str = '') { $reserved = array('AND', 'OR', 'IN', 'NOT'); foreach ($this->searchArray as $key => $term) { $this->searchArray[$key] = strip_tags($term); - if (strlen($term) < $minChars && in_array($term, $reserved)) { + if (iconv_strlen($term) < $minChars && in_array($term, $reserved)) { unset($this->searchArray[$key]); } } From d1f11f0f4942e9f177b65fc0865cd510f8c621cf Mon Sep 17 00:00:00 2001 From: Ruslan-Aleev Date: Mon, 31 Aug 2020 20:57:34 +0300 Subject: [PATCH 3/3] Changed minChars according to the documentation --- .../simplesearch/model/simplesearch/simplesearch.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/simplesearch/model/simplesearch/simplesearch.class.php b/core/components/simplesearch/model/simplesearch/simplesearch.class.php index fe6a498..42ee304 100644 --- a/core/components/simplesearch/model/simplesearch/simplesearch.class.php +++ b/core/components/simplesearch/model/simplesearch/simplesearch.class.php @@ -144,7 +144,7 @@ public function loadDriver(array $scriptProperties = array()) { * @return string The parsed and cleansed string. */ public function parseSearchString($str = '') { - $minChars = $this->modx->getOption('minChars', $this->config, 4); + $minChars = $this->modx->getOption('minChars', $this->config, 3); $this->searchArray = explode(' ',$str); $this->searchArray = $this->modx->sanitize($this->searchArray, $this->modx->sanitizePatterns);