Welcome Guest, Not a member yet? Register   Sign In
URL Decoding Issue
#1

[eluser]emelpy[/eluser]
Hey guys,

I am having an issue with CodeIgniter decoding my urls and redirecting to the decoded location.

I have a controller that accepts search string in the url like so:

Code:
http://www.mydomain.com/controller/function/q/foo

Where foo is the string to search on. I would like allow users to include slashes in their search so I did this by encoding slashes into their respective character code(2F). So the url would look as follows:

Code:
http://www.mydomain.com/controller/function/q/foo%2Fbar

Unfortunately it seems that CI is decoding the url and redirecting to the decoded location. in this example it would try to go to

Code:
http://www.mydomain.com/controller/function/q/foo/bar

which causes an error to be thrown. An 'Object not found' error, to be specific. I know it is trying to redirect to this location because when I try putting in other restricted characters(a single quote, for instance), an error is thrown which states that the url contains a disallowed character, even though the character was decoded.

Thanks for any help you can provide.

Regards,
Curtis
#2

[eluser]WanWizard[/eluser]
That's strange, because CI only checks the first two segments of the URI to determine the controller and method name. It doesn't do anything with the rest. It also doesn't redirect by default.

I think the issue here is that there is a difference in behaviour of percent encoded characters between the path and the query string of the URI. In the query string, / is translated to a slash, in the path it isn't ( so "foo% 2Fbar" means a directory or file named "foo/bar", not a file called bar in a directory called foo!).

note: I had to insert the space between the % and the 2F above, this forum seems to url_decode the message...




Theme © iAndrew 2016 - Forum software by © MyBB