Jason Huck Posted October 4, 2016 Share Posted October 4, 2016 Am I right in understanding that there's no way to escape or encode a dash ("-") for use within a selector value (that has to be sanitized)? Looking at the code for $sanitizer it looks like it's just converted to a space. That seemingly makes it impossible to search for terms like "x-ray." Any workarounds for this? Link to comment Share on other sites More sharing options...
Robin S Posted October 4, 2016 Share Posted October 4, 2016 Works for me. I put x-ray into the body field on page 'Three' and got this result in Selector Test: Edit: just realised you're asking about selector values that are going through a sanitizer. Not sure which sanitizer you are using, but $sanitizer->text() keeps dashes intact. 1 Link to comment Share on other sites More sharing options...
kongondo Posted October 4, 2016 Share Posted October 4, 2016 Really? So, we cannot have pages titled "X-Ray" then? echo '<pre>'; print_r($sanitizer->testAll('x-ray')); echo '</pre>'; // results Array ( [name] => x-ray [names] => x-ray [varName] => x_ray [fieldName] => x_ray [templateName] => x-ray [pageName] => x-ray [pageNameTranslate] => x-ray [filename] => x-ray [path] => x-ray [pagePathName] => x-ray [email] => [emailHeader] => x-ray [text] => x-ray [textarea] => x-ray [url] => x-ray [selectorField] => x_ray [selectorValue] => x-ray [entities] => x-ray [entities1] => x-ray [unentities] => x-ray [entitiesMarkdown] => x-ray [purify] => x-ray [string] => x-ray [date] => [int] => 0 [intUnsigned] => 0 [intSigned] => 0 [float] => 0 [array] => Array ( [0] => x-ray ) [intArray] => Array ( [0] => 0 ) [bool] => 1 ) http://processwire.com/api/variables/sanitizer/ 1 Link to comment Share on other sites More sharing options...
netcarver Posted October 4, 2016 Share Posted October 4, 2016 I have a load of sanitised values containing '-' characters that I successfully use in selectors; I'm working with one at the moment. It's disallowed from sanitised field names though - as they get translated to PHP variable names and have to follow the same rules. Link to comment Share on other sites More sharing options...
Jason Huck Posted October 5, 2016 Author Share Posted October 5, 2016 Whoops, my bad. I had read this: http://cheatsheet.processwire.com/sanitizer/properties-and-methods/sanitizer-selectorvalue-value/ ...combined with this: http://processwire.com/api/selectors/#sanitizing ...and spotted this: https://github.com/processwire/processwire/blob/master/wire/core/Sanitizer.php#L1506 ...and since searches containing dashes weren't working in this project, had come to the conclusion that $sanitizer->selectorValue() considered dashes to be illegal characters and was replacing them with spaces, but that's clearly not the case. I've since discovered that dashes are ignored characters by default in the Indexer module, which is what I'm using for search. I've taken that character out of the Ignored Characters field and reindexed all objects, but still not getting results. Most likely some old results are cached somewhere. I'll verify dashes are actually present in the indexer field, and take it from there. Thanks for the clarification! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now