In the 'Highlighting' processor, the search keys are not escaped for special characters. This can break the regular expression.
An example query that is not properly escaped: 'drupal + search_api'
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2159011-4--highlighting_preg_quote.patch | 777 bytes | drunken monkey |
| #1 | search_api-escape-highlighting-input-2159011-1.patch | 840 bytes | idebr |
Comments
Comment #1
idebr commentedAttached patch preg_quotes the search keys before the keys are inserted into the regular expression
Comment #2
idebr commentedComment #3
idebr commentedComment #4
drunken monkeyAh, you're right! Thanks for spotting this and providing a fix! Don't know how that slipped past me, with regular expressions I'm normally extra-careful …
Anyways, I think the attached form of the patch is more readable, the
foreachloop can easily be replaced by aarray_map()call.Comment #5
drunken monkeyComment #6
idebr commentedYes, that is definitely better than #1. Simple and elegant, I like it!
Comment #7
drunken monkeyExcellent, good to hear!
Committed.
Thanks again for your contribution!