Fix searching when apostrophe and space both in page title
Searching for a page title that contains both an apostrophe and a space doesn't work: it finds the page, but the redirection chain mangles the URL, ending up on a ‘no such article’ page.
For instance, searching for “The La's”:
$ HEAD -S "https://www.wikiwand.com/en/Special:Search?search=The%20La's"
HEAD https://www.wikiwand.com/en/Special:Search?search=The%20La's
302 Moved Temporarily
HEAD https://www.wikiwand.com/en/The%20La's
301 Moved Permanently
HEAD https://www.wikiwand.com/en/The_La%27s/en/The%20La's
200 OK
(Here I'm using the HEAD command-line tool to show the redirect chain. In real use this would be a Firefox bookmark of the search URL with the ‘%s’ placeholder for the search term like this https://www.wikiwand.com/en/Special:Search?search=%s — with the keyword set to ‘w’, then typing “w The La's” into Firefox's URL bar.)
It works fine with only a space:
$ HEAD -S "https://www.wikiwand.com/en/Special:Search?search=The%20Smiths"
HEAD https://www.wikiwand.com/en/Special:Search?search=The%20Smiths
302 Moved Temporarily
HEAD https://www.wikiwand.com/en/The%20Smiths
301 Moved Permanently
HEAD https://www.wikiwand.com/en/The_Smiths
200 OK
And with only an apostrophe:
$ HEAD -S "https://www.wikiwand.com/en/Special:Search?search=Ain't"
HEAD https://www.wikiwand.com/en/Special:Search?search=Ain't
302 Moved Temporarily
HEAD https://www.wikiwand.com/en/Ain't
200 OK
It's also fine if the search term doesn't match a page title exactly, thereby showing the ‘no article’ page, with the intended article in the list:
$ HEAD -S "https://www.wikiwand.com/en/Special:Search?search=The%20la's"
HEAD https://www.wikiwand.com/en/Special:Search?search=The%20la's
302 Moved Temporarily
HEAD https://www.wikiwand.com/en/The%20la's
200 OK
You can work round the bug by searching for an underscore instead of a space:
$ HEAD -S "https://www.wikiwand.com/en/Special:Search?search=The_La's"
HEAD https://www.wikiwand.com/en/Special:Search?search=The_La's
302 Moved Temporarily
HEAD https://www.wikiwand.com/en/The_La's
200 OK
The bug only seems to get triggered when there is all four of:
• the search term is an exact article title
• the article title has at least one apostrophe in it
• the article title has at least one space in it
• the search term contains an actual space (%20), not an underscore
And actually you don't need to use Wikiwand's search facility to trigger this behaviour: you can get it by manually typing an article URL for an article with an apostrophe in it but using spaces instead of underscores. (That's less reasonable user behaviour though: spaces should work in search terms, because they are human-language phrases; URLs are not supposed to contain spaces, so anybody manually constructing a page URL should be prepared to write it in the correct form.)
-
Anonymous commented
420 kush dispensary may be a respectable on line dispensary shipping global. Order from us and attain cut price coupons, We are a Marijuana Dispensary. From seed to sale.
420 kush dispensary | Top quality medical marijuana | Pure cocaine online
-
Smylers commented
Gah, this web form has also mangled the example URLs!
None of those “"”s should be part of the URLs themselves; they are the closing quote mark after the URL, balancing the one just before it (to pass the entire URL as a single shell argument to the HEAD command, required because of the apostrophes).
Fortunately, in each case the correct URL appears on the following line, echoed by the HEAD command.