grav-plugin-simplesearch icon indicating copy to clipboard operation
grav-plugin-simplesearch copied to clipboard

forward slash in query string causes Error 404

Open gitname opened this issue 9 years ago • 5 comments

Grav allows taxonomy terms to contain forward slashes.

For example, the AC/DC in:

title: Back in Black
taxonomy:
    genre: Rock
    artist: AC/DC

---

However, when processing a search query that contains a forward slash, Grav displays an Error 404 page. For example:

screen shot 2016-11-02 at 1 39 31 pm

Here is the URL of that page on the Grav Blog Skeleton demo site: https://demo.getgrav.org/blog-skeleton/search/query:AC/DC

For comparison, when processing a search query that does not contain a forward slash (but still doesn't match any pages), Grav displays a "found 0 results" page. For example:

screen shot 2016-11-02 at 1 41 11 pm

Here is the URL of that page on the Grav Blog Skeleton demo site: https://demo.getgrav.org/blog-skeleton/search/query:ACDC

gitname avatar Nov 02 '16 20:11 gitname

What happens if you do use the urlencode %2F instead of / ?

/search/query:AC%2FDC

w00fz avatar Nov 02 '16 20:11 w00fz

@w00fz, here's what the Grav Blog Skeleton demo site shows:

screen shot 2016-11-02 at 1 48 06 pm

URL shown in screenshot: https://demo.getgrav.org/blog-skeleton/search/query:AC%2FDC

gitname avatar Nov 02 '16 20:11 gitname

Oh sorry I didn't realize I could test on our demo. I can see this being an issue because the / is a URI sensitive separator which indicates subpathing, however urlencoding should work.

We'll look into it. Cheers.

w00fz avatar Nov 02 '16 20:11 w00fz

Thanks!

P.S. Whoever looks into it may want to keep Issue #71 in mind as well, as it, too, involves the processing of search queries.

gitname avatar Nov 02 '16 20:11 gitname

I found a way to prevent this from happening with characters like ":" or "/". You need to use real GET parameters. For example, replace "/myurl/page.json/query:search_string" to "/myurl/page.json?query=search_string".

In JS, use the function encodeURIComponent to encode the search_string before.

@w00fz : The problem can be reproduced on https://learn.getgrav.org/. Maybe my solution can solve the problem!

pfcloutier-druide avatar Jun 07 '17 16:06 pfcloutier-druide