mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Fix typos and check-in Escaper
This commit is contained in:
19
lib/Alchemy/Phrasea/SearchEngine/Elastic/Search/Escaper.php
Normal file
19
lib/Alchemy/Phrasea/SearchEngine/Elastic/Search/Escaper.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Phrasea\SearchEngine\Elastic\Search;
|
||||
|
||||
class Escaper
|
||||
{
|
||||
public function escapeWord($value)
|
||||
{
|
||||
// Strip double quotes from values to prevent broken queries
|
||||
// TODO escape double quotes when it will be supported in query parser
|
||||
$value = str_replace('/["\(\)\[\]]+/u', ' ', $value);
|
||||
|
||||
if (preg_match('/[\s\(\)\[\]]/u', $value)) {
|
||||
return sprintf('"%s"', $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user