CodeIgniter Forums
urlencoded percent sign is causing "Bad Request" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: urlencoded percent sign is causing "Bad Request" (/showthread.php?tid=41033)



urlencoded percent sign is causing "Bad Request" - El Forum - 04-26-2011

[eluser]dtrenz[/eluser]
My URI looks like this:

Code:
http://www.mydomain.com/search/100%25+Fail

My permitted_uri_chars: 'a-z 0-9~%.:_+\'\-'

Does anybody have any idea why I'm getting "Bad Request" for this URI, even though % is a permitted char?

Thanks! -d


urlencoded percent sign is causing "Bad Request" - El Forum - 04-26-2011

[eluser]vrencianz[/eluser]
You have to encode the search value. It must look like:
Code:
100%25%2BFail%20%20



urlencoded percent sign is causing "Bad Request" - El Forum - 04-26-2011

[eluser]dtrenz[/eluser]
sorry, i meant to put this as the URI:

Code:
/search/100%25+Fail

...where the unencoded search value is "100% Fail"


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]vrencianz[/eluser]
if your 'search' points directly to a controller (named 'Search') the engine tries to call its method named '100% Fail' This is not possible.

I didn't try, but, eventually, you can try using a remapper as Remapping Function calls describes.


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]dtrenz[/eluser]
No. I'm already routing "/search/(:any)" to "/search/index/$1" so that is not the issue. The issue is specifically with the percent sign being treated as a disallowed character despite being in the permitted_uri_chars white list. :/


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]vrencianz[/eluser]
You have right Smile. Sorry.

This cannot be fixed inside codeigniter or web servers. See Apache Web Server Forum for details.

You have to enable query strings, I think.


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]louisl[/eluser]
Seeing as people could type any old rubbish into a free text seach box you'd probably be better off hashing the url segment after search/ then unhashing it to make sense of it for your query.


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]dtrenz[/eluser]
None of this makes sense. The percent sign is being URL ENCODED. By definition, CI should not care about it since it is encode. And even if it DID, I am allowing percent signs, so what gives?!

Also, when I set permitted_uri_chars to an empty string (a/k/a allow all) I don't get this error, so this is clearly a CI bug, not an Apache issue.


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]InsiteFX[/eluser]
Read - RFC 3986

2.1. Percent-Encoding

A percent-encoding mechanism is used to represent a data octet in a
component when that octet's corresponding character is outside the
allowed set or is being used as a delimiter of, or within, the
component. A percent-encoded octet is encoded as a character
triplet, consisting of the percent character "%" followed by the two
hexadecimal digits representing that octet's numeric value. For
example, " " is the percent-encoding for the binary octet
"00100000" (ABNF: %x20), which in US-ASCII corresponds to the space
character (SP). Section 2.4 describes when percent-encoding and
decoding is applied.

pct-encoded = "%" HEXDIG HEXDIG

The uppercase hexadecimal digits 'A' through 'F' are equivalent to
the lowercase digits 'a' through 'f', respectively. If two URIs
differ only in the case of hexadecimal digits used in percent-encoded
octets, they are equivalent. For consistency, URI producers and
normalizers should use uppercase hexadecimal digits for all percent-
encodings.

InsiteFX


urlencoded percent sign is causing "Bad Request" - El Forum - 04-27-2011

[eluser]dtrenz[/eluser]
Damn! I just realized that forum keeps rendering my encoded percent sign. Ugh.

You all must think I'm crazy.