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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jdanthinne’s picture

Version: 7.x-1.13 » 7.x-1.x-dev
Status: Active » Fixed

Thanks for the patch! It has been pushed to DEV.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alcroito’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review
FileSize
857 bytes

It 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.

jdanthinne’s picture

Status: Needs review » Fixed

Thanks. This is fixed.

  • jdanthinne committed e78b1b4 on 7.x-1.x
    [#2118723] by Placinta: fixed typo in javascript.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.