The custom_search.js code looks through the search string looking for 'type:', 'term:' and 'language:' but the code doesn't work as intended as:
var pos = edit_keys.indexOf('type:');
will equal:
- -1 if the string is not found,
- 0 if the string is at the start of the search text,
- 1+ if the string is further in the search text.
The next line:
if (pos) {
is the issue - pos will evaluate to TRUE for any number except 0 so the if statement is executed for all cases except if the string searched for is not in the text. What you actually want is for the if statement to be executed if pos is not -1.
It doesn't normally cause an issue but if there is an @ character in the search text (eg an email address) then a javascript error occurs.
eg with the search "email@address.com" the error is:
Uncaught Error: Syntax error, unrecognized expression: .search-form input:checkbox[value=l@address.com]
I've included a patch that changes the checks in the if statements concerned.
Cheers,
Alan.
Comment | File | Size | Author |
---|---|---|---|
#3 | custom_search-fix_js_typo-2118723-3.patch | 857 bytes | alcroito |
custon_search_js_fix_indexof_checks.patch | 1 KB | Altcom_Alan |
Comments
Comment #1
jdanthinne CreditAttribution: jdanthinne commentedThanks for the patch! It has been pushed to DEV.
Comment #3
alcroito CreditAttribution: alcroito commentedIt appears that the patch wasn't applied correctly (probably manually), because there is a typo in one of the JS conditional checks.
Attaching a new patch, that fixes that typo, thus fixing a javascript error.
Comment #4
jdanthinne CreditAttribution: jdanthinne commentedThanks. This is fixed.