staticSearch
staticSearch copied to clipboard
Ampersands function in initial phrasal search, but are not correctly restored from URL
If you use an ampersand in a phrasal search, then reload the search page, the ampersand causes the phrasal search to be decomposed and only the word before the ampersand is used for the search. This looks like a straightforward JS error in the code assigning or parsing the URL query string. The bug is clear in the 1.4 release branch; I haven't tested it yet in the dev branch. Thank you to Adam from the TMP project for pointing me at this.
I'm going to work on this in a branch from dev to test whether it happens there, and if it does, fix it there, then backport to 1.4. The branch is iss-293-ampersands.
The first finding is that searching for the exact phrase "Marks & Spencer" does not find it, but if you escape the ampersand to &
, it is found, and that search is correctly re-run from the URL. So it appears that what we need to do is:
- When running a text search, silently escape ampersands in the input text, without changing them in the input text box.
- When restoring search terms from a URL, unescape ampersands before putting text containing them back in the search box.
I'm happy to see that it doesn't matter what configuration of the escaped ampersand appears in the original text; all of these are found with a single search term "Marks & Spencer":
Marks & Spencer
Marks & Spencer
Marks & Spencer
This is because all these forms are normalized to Marks & Spencer
by the stemmer when it creates the kwics.
No sign of problems with this, so I'm closing it.