mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
Fix typos and check-in Escaper
This commit is contained in:
@@ -77,7 +77,7 @@ class SearchEngineServiceProvider implements ServiceProviderInterface
|
||||
});
|
||||
|
||||
$app['elasticsearch.facets_response.factory'] = $app->protect(function (array $response) use ($app) {
|
||||
return new FacetsResponse(new Excaper(), $response);
|
||||
return new FacetsResponse(new Escaper(), $response);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineResult;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Closure;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
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