Jump to content

search 'rar' and 'tar' result in 404


Macrura
 Share

Recommended Posts

I have a site with a search form similar to the skyscrapers profile.

the strange thing is that if you put in a keyword for 'guitar' and a 2nd keyword (anything), a 404 is triggered (!)...

I can't figure out why this is happening, there are no errors in the log and no messages in the console;

all other keywords work fine, just the word 'guitar' + another word triggers the 404 not found...

Link to comment
Share on other sites

did some more testing; it's not about the word guitar, it's all words ending in tar, and the word rar when placed in the querystring before another keyword, so that those endings are followed by a + sign.

the problem seems to be related to the get string using the + instead of the encoded version of the + which is %2B? if i use %2B in the querystring then it works;

also not sure why i have to to the str_replace on my keywords to get my selector to work

if($input->get->keywords) {
    $keywords = $sanitizer->selectorValue($input->get->keywords);
    $keysearch = str_replace(' ', '|', $keywords);
    $selector .= "title|body%=$keysearch, ";
    $summary["keywords"] = $sanitizer->entities($keywords);
    $input->whitelist('keywords', $keywords);
}

wouldn't the sanitizer selectorValue do this for me?

if i don't so that str_replace, my selector comes out like this and it doesn't work:

title|body%=guitar lessons

if i do the str_replace, my selector looks like this:

title|body%=guitar|lessons
Link to comment
Share on other sites

This one is solved as far as the 404 - i just received a reply from the hosting people:

I confirmed that those were blocked by our mod_security rules.

still would be good to figure out about sanitizing keywords fields the correct way...

  • Like 1
Link to comment
Share on other sites

 

if i don't so that str_replace, my selector comes out like this and it doesn't work:

title|body%=guitar lessons

if i do the str_replace, my selector looks like this:

title|body%=guitar|lessons

Those are two different selectors. The first is looking for pages with the phrase "guitar lessons" in title or body. The second is looking for pages with the words "guitar" OR "body" in the title or body. If the first one is failing, then that would be because the phrase "guitar lessons" don't appear in the body of any pages exactly like that (though this is not case sensitive). This sort of thing can be affected by spacing too, so if you see "guitar lessons" on a page, view the source and see if there are actually two spaces between the words or perhaps a pesky   or something. You might also want to consider if "title|body~=guitar lessons" might be better for your needs here. That would match pages having both of the words in either the title or body, but they wouldn't have to be phrased together. 

Link to comment
Share on other sites

Those are two different selectors. The first is looking for pages with

the phrase "guitar lessons" in title or body. The second is looking for

pages with the words "guitar" OR "body" in the title or body.

aah - right, got it - thanks; so the str_replace seems the right way to parse a bunch of words into a pipe separated list, for use in the selector...

which brings up another question - i have a keywords field in my template which is a page field (asm select multi) -- how can i compare the keywords entered by a search user with the keywords that are selected/entered in the page?  i get MySQL errors so far when trying to work with that keywords field... gonna be tricky i guess, i'm doing a skyscrapers style search box with several dropdown selects and a keywords field

Link to comment
Share on other sites

aah - right, got it - thanks; so the str_replace seems the right way to parse a bunch of words into a pipe separated list, for use in the selector...

Rather than str_replace'ing in pipes, I'd suggest just using the "~=" operator to perform your search. That way it will track down your words without them having to be next to each other. It also requires that all the words are actually present, unlike "|" which is essentially saying "this OR that". I gather you probably want "this AND that", so ~= would fit the bill. 

which brings up another question - i have a keywords field in my template which is a page field (asm select multi) -- how can i compare the keywords entered by a search user with the keywords that are selected/entered in the page?  i get MySQL errors so far when trying to work with that keywords field... gonna be tricky i guess, i'm doing a skyscrapers style search box with several dropdown selects and a keywords field

If the keywords are page references, then you probably have to stop thinking of them as keywords and more as categories or tags, at least from the development side, and code it the same way. I'm assuming your keywords field is named "keywords" and that the words are stored in the "title" field. You could attempt to match the title of the keyword pages for all the words: "keywords.title~=guitar lessons". You could attempt to match the the title of the keyword pages for any of the words: "keywords.title*=guitar|lessons". 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...