[4275]Search function bug related to member with a space (" ") in their name

Started by Brettflan, April 07, 2010, 05:08:32 AM

Previous topic - Next topic

Brettflan

Here's the how to reproduce this bug. Go to the advanced search form, enter a search term, and then in the "By user" box, enter a username which contains a space character (" ") in it. For instance, here's an example of the first page of results for such a search here on SM.org:
Example Search

The first results page is fine, the problem only occurs when you click over to another page (2, 3, 4, whatever) or click the "Search Results" link at the end of the linktree, basically anything that uses the encoded "params" value in the link. All such links fail. As far as I've seen, this problem does not occur with searches on usernames which don't have a space character in them.
Not that it's really all that relevant, but with Sphinx you just get results from any user rather than the one you were searching under, while without using a search index at all you instead just get "no results" back.

The problem seems to be with it storing and using the username in its urlencoded format, where "Jade Elizabeth" = "Jade+Elizabeth", and not correcting for that afterwards.
I should note that testing and debugging this problem is a real pain, since the search results and/or query (at least while I was working on it) seem to be cached somewhere down the line. So if you get those messed up results and then apply a working fix, you'll probably still see the bugged results at least for a while. Confused me to no end trying to debug it, seeing bad results, trying something else, then seeing fixed results, then still seeing fixed results after removing all changes, etc. :P
I finally did narrow it down to one thing which worked on a fresh site backup (file cache emptied) running on a freshly rebooted VM just to make sure all other caches were cleared out (Sphinx, MySQL, APC, whatever).

EDIT: narrow fix removed. This problem is related to a wider Search problem discussed here:
http://www.simplemachines.org/community/index.php?topic=371048.0


Brettflan

Quote from: flapjack on April 07, 2010, 07:15:04 AM
isn't it the same bug for all the searches?
Can you elaborate? I don't understand what you're trying to say without further details.

If you don't understand for whatever reason, here, let's do a comparison. Open both of the following search links and click on the page "2" link for both. Notice a problem with page 2 for the first link and not the second?
Search for "fast" by user Jade Elizabeth (space in name)
Search for "fast" by user Arantor (no space in name)

Arantor

No, flapjack is right.

There is an identical bug in the main search code too, where spaces are being converted to + in the string, then the string inserted for next time is with + instead of space.

ETA: http://www.simplemachines.org/community/index.php?topic=371048.0
Holder of controversial views, all of which my own.


Brettflan

Ah, that's true then, they do appear to be related. I've just replicated that one as well.

Norv

To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Advertisement: