Jump to content

Selector and accents


sebr
 Share

Recommended Posts

Hi

In my search page, I used a selector like this :

$searchQuery = $sanitizer->entities($input->get('q'));
$searchQuery = $sanitizer->selectorValue($searchQuery);
$selector = 'title|subtitle|summary|html_body_noimg~=' . $searchQuery;
$matches = $pages->find($selector);

I don't have the same results if $searchQuery contains accent or not.

For example,

  • with « bâtiment » I have no result
  • with « batiment » I have onea result : « Les bâtiments et les smart-city »

Normally I should have the same results? How can I do that ?

Thanks for your help

Link to comment
Share on other sites

1 hour ago, sebr said:

$searchQuery = $sanitizer->entities($input->get('q'));

This line is the problem. It is messing up the selector string (see screenshot below). $sanitizer->entities is for entity encoding a string for output ( i.e. output to your page). What we want here is for input, hence $sanitizer->selectorValue should be enough. Remove the entities sanitizer (or use $sanitizer->text in its place to remove HTML) and you should get same results:

sanitized selector

sanitizer-entities-messing-up-selector1.thumb.png.5027652c90363f5145a3b2775d711057.png

 

results

sanitizer-entities-messing-up-selector2.thumb.png.f25e6c8d8f58e957e16aedba5a188167.png

 

Edited by kongondo
clarification
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...