Searching does not match for "special" characters #/- etc. in search string...

Started by MarcoDings, February 09, 2012, 23:10:47 PM

Previous topic - Next topic

MarcoDings

Hi

Using Joomla 2.51 and VM 2
The search for normal strings seems to work and returns matched products
so searching for 10055501 or VA1932WM return the products with these strings in the product details ( as set up / configured )

Searching for strings such as
NK570AA#ABA
LF24MGSLBM/ZA
SGJBVG-12389

however fails even though the strings are in the product details

searching for substrings of the above ( not including # / - and possibly others ) , say:
NK570AA
LF24MGSLBM

does find the products mentioned

Since these strings represent manufacturer numbers its not logical for the customer to
try these "partials". The limitation of not beeing able to search for " # / - and possibly more"
illudes me why if report it as a BUG ..

Milbo

Hmmm this is a problem of a too strict security. Thanks for pointing out. We must find a good mix of forbidden chars and the one we just need, like #,-,_,/ . They are used a typical delimiters.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

nflmerch

Sorry this isn't the same problem, but the search function is limited in other ways as well.
For instance plurals do not work:
I have many Flasks in my store, but if I type in "FLASKS" it produces no results.   "FLASK" produces all results as expected.

I know I've been told already that it is not in the plans to fix that, but I can't help but point out that something so basic also seems more like a bug.

Imagine how many people go to a website and search, for example, "GREEN BAY PACKERS HATS"  instead of "GREEN BAY PACKERS HAT"..
... almost everyone in the USA!!!   ;)



Milbo

loool nflmerch, sorry, but ehrm, that is absolute standard. Using a search must be also learned and one of the first things I explain people using the first time things like google that it is always better to search for the root of a word and not deflected ones. Btw that is the way the big search engines make money. They invest millions of dollars in algorythm doing that. It is not possible anylonger to test it yourself, but years ago, even google was not able todo that. They started with "Search instead for", after years of showing that, it directly changed the keywords automatically. But that took some years of development. I know already that 3rd party developers write that. But be aware there exists NO generic solution. It must be adjusted to every language.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

nflmerch

Thanks for the explanation, I understand.   

Also, I discovered the search will find the plural if you name the category as the plural.
So for example, even if I only have one product that is a "Mug" that is in the category "Dinnerware", if I also put it in a category named "Mugs", then the search will find it if someone types in "mugs".

MarcoDings

Quote from: Milbo on February 10, 2012, 00:39:27 AM
Hmmm this is a problem of a too strict security. Thanks for pointing out. We must find a good mix of forbidden chars and the one we just need, like #,-,_,/ . They are used a typical delimiters.
Can you point me in the direction ( source files where i can patch this for myself) for the time beeing, knowing it will get solved.

MarcoDings

bump..

any progress on this issue "Searching does not match for "special" characters #/- etc. in search string..." ??

I could not find a reference in release notes to date 2.03h

Cheers Marco


rippergr

I found a solution for this problem. I changed the file config.php in /administrator/components/com_virtuemart/helpers/
in line 812
return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);
to
return mb_ereg_replace('/[^\w'.preg_quote($custom).']/', '', $source);
The problem is that virtuemart search filter all special characters and returns no results.
With this tweak it working great.
I don't know if there is any problem with security issues. Use it with your own responsibility
Visit my webpage www.comworld.gr


Jason Farmer

Quote from: rippergr on May 07, 2012, 15:01:38 PM
I found a solution for this problem. I changed the file config.php in /administrator/components/com_virtuemart/helpers/
in line 812
return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);
to
return mb_ereg_replace('/[^\w'.preg_quote($custom).']/', '', $source);
The problem is that virtuemart search filter all special characters and returns no results.
With this tweak it working great.
I don't know if there is any problem with security issues. Use it with your own responsibility


now Line 919 in  /administrator/components/com_virtuemart/helpers/config.php for vm 2.0.12b

[tr][td][/td][td]
Development[/td][td]Production[/td][/tr]
[tr][td]VirtueMart   [/td][td]
2.0.12b
[/td][td]
1.1.3
[/td][/tr]
[tr][td]Joomla!   [/td][td]
2.5.6
[/td][td]
1.5.14
[/td][/tr]
[tr][td]Mysql  [/td][td]
5.5.8
[/td][td]
5.0.51
[/td][/tr]
[tr][td]PhP   [/td][td]
5.3.5
[/td][td]
5.2.4
[/td][/tr]
[/table]

huntc00

Above solutions didn't work for me. After trying several option I solved this problem as followed:


I changed:

return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);

To:

return mb_ereg_replace('-/[^\w'.preg_quote($custom).']/-', '', $source);

Now I can use the VM search module to search for productnumbers like: A-100001

Edit: I'm using Joomla 2.5.6 and VM 2.0.12b

kittmaster

Quote from: huntc00 on November 02, 2012, 22:45:14 PM
Above solutions didn't work for me. After trying several option I solved this problem as followed:


I changed:

return mb_ereg_replace('[^\w'.preg_quote($custom).']', '', $source);

To:

return mb_ereg_replace('-/[^\w'.preg_quote($custom).']/-', '', $source);

Now I can use the VM search module to search for productnumbers like: A-100001

Edit: I'm using Joomla 2.5.6 and VM 2.0.12b

I'm logging in to confirm that this solution worked for me also when you need to search for wildcards and want to see it in the return results without being stripped out.

The file to mod is as mentioned > /administrator/components/com_virtuemart/helpers/config.php

vixbow

Is there a way to use overrides in the Administrator folder (mentioned above) so that this hack doesn't get overwritten?

Thanks in advance!

datalabsys

VirtueMart 3.0.18
Joomla! 3.8.2

i have exactly the same issue here and im at the latest version of VM and Joomla....and this problem is the same since version 2.... any fixes? The lines you are advising to change do not exist anymore in VM version 3.