[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] swish search - quotes


Quoting Peter <suppressed>:

On 02/07/2007 01:06 PM, Dan Bergan wrote:
However it looks like I will have to do some hacking in Swish.pm it
looks like quotes are always removed as "unsafe charachers":
$spec =~ s/[^-\w()"\s\*]+//g
    and $CGI::values{debug}
    and ::logError("Removed unsafe characters from search string");

(My regex skills may be a bit rusty, so please correct me if I'm reading
either of these wrong!)

Does this seem like a reasonable thing for me to do in Swish.pm:
#removed quote char (") from regex
$spec =~ s/[^-\w()\s\*]+//g
    and $CGI::values{debug}
    and ::logError("Removed unsafe characters from search string");

You got it backwards, the ^ negates the character set, so it's removing
characters that *don't* match anything in the set.  " is explicitly allowed.

Peter


Thanks, Peter!  I guess my regex skills were a bit rusty!

To allow phrase searching I added the following line:
$spec =~ s/"/\\"/g;

Now, if someone searches for "word1 word2" (with the quotes included in the search box), it will return only those results where that exact phrase appears in the page.

Thanks for everyones help!
Dan



_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.