Search with a space at the end

If you have an extra space at the end of a search query on the storefront, it seems to ignore the search query and just spits out a list of all products.

I have two sites, one running 2.0.7 the other 2.0.12, both exhibit the same behavior.

Strangely, this does not happen in the demo store.

Can anyone replicate this in their own store?

not for me. perhaps you could add a string replace on the query (if you can find it) to remove spaces?

needless to say though this doesnt appear to be a default bug, so it must be something you have done…

I haven’t done any customization, save for graphics and control panel settings.

I have the same problem. For the most part it doesn’t matter, but sometimes when I copy / paste it keeps that last extra space and then gives me the same “error”. It would be nice if CS-Cart would just ignore the trailing space.


The only way I can get it to trim correctly is in fn.catalog.php by adding it around line 2726

```php // Search string condition for SQL query

if (!empty($params[‘q’])) {

//trim off excess space from search

$params[‘q’] = rtrim($params[‘q’]); ```

Though for some reason, if you have search pages and site news turned on, this change causes all of those items to come up any time a space was trimmed. Really bizarre behavior.