From 7a0e9d4dc1a0f280d8d509f02889296fa28fd565 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Thu, 6 Mar 2025 03:56:05 +0100 Subject: [PATCH] Accept utf8 chars in the natural_search in mode 3. Close #32930 --- htdocs/core/db/DoliDB.class.php | 4 ++-- test/phpunit/FunctionsLibTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 3a2346c2356..1caa8d6dcdf 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -186,8 +186,8 @@ abstract class DoliDB implements Database */ public function sanitize($stringtosanitize, $allowsimplequote = 0, $allowsequals = 0, $allowsspace = 0, $allowschars = 1) { - //$result = preg_replace('/[^0-9_\-\.,'.($allowschars ? '\p{L}' : '').($allowsequals ? '=' : '').($allowsimplequote ? "\'" : '').($allowsspace ? ' ' : '').']/ui', '', $stringtosanitize); - $result = preg_replace('/[^0-9_\-\.,'.($allowschars ? 'a-z' : '').($allowsequals ? '=' : '').($allowsimplequote ? "\'" : '').($allowsspace ? ' ' : '').']/i', '', $stringtosanitize); + $result = preg_replace('/[^0-9_\-\.,'.($allowschars ? '\p{L}' : '').($allowsequals ? '=' : '').($allowsimplequote ? "\'" : '').($allowsspace ? ' ' : '').']/ui', '', $stringtosanitize); + //$result = preg_replace('/[^0-9_\-\.,'.($allowschars ? 'a-z' : '').($allowsequals ? '=' : '').($allowsimplequote ? "\'" : '').($allowsspace ? ' ' : '').']/i', '', $stringtosanitize); if ($allowsimplequote == 1) { // Remove all quotes that are inside a string and not around diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 7f585eed557..67c3e13b816 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1954,7 +1954,7 @@ class FunctionsLibTest extends CommonClassTest var_dump($s); */ - //$s = natural_search("t.field", "KØB", 3); // mode 3 is to provide a list of string separated with coma - //$this->assertEquals(" AND (t.field IN ('KØB'))", $s); + $s = natural_search("t.field", "KØB", 3); // mode 3 is to provide a list of string separated with coma + $this->assertEquals(" AND (t.field IN ('KØB'))", $s); } }