If you search for a string with white space, it will save the string WITH white space into this.searchString, but it'll search for that string WITHOUT white space, because

searchString = searchString.replace(/^\s+|\.{2,}\/|\s+$/g, '');

so when it gets the results and is about to show them, it compares the 2 strings (which are different):

if (db.searchString == searchString) {
  db.owner.found(matches);
}

The fix couldn't be easier: save the string AFTER trimming it, because that's the only string actually used anywhere.

Comments

rudiedirkx created an issue. See original summary.

rudiedirkx’s picture

Status: Active » Needs review
StatusFileSize
new722 bytes

Very simple patch.

poker10’s picture

Status: Needs review » Postponed (maintainer needs more info)

Unfortunatelly I am not able to reproduce the issue. The regexp seems to be removing only starting and trailing whitespaces. If I search for a string with whitespace in it (like "test test"), it is found correctly (the middle whitespace is not removed). Can you please provide more information what is wrong here?

I have found one similar issue: #1221612: Autocomplete with trailing space, but according to the issue summary this does not seems to be the same problem.

Thanks!

Status: Postponed (maintainer needs more info) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.