How is it guaranteed to check that the line went through urlencode and the line must be urldecode through urldecode before working with it?
|
2 answers
If you want to check in general any arbitrary string. That most likely will not work. IMHO you are looking for a problem in the wrong place, most likely the architectural trabl and you should make sure that a string is sent to urlencode once or to save an unchanged string.
|
Check for the presence of the = sign in the string, in the encoded one it will look like %3 :
$param1 = "beyong"; $param2 = "galvanize"; $qs = urlencode("param1=$param1¶m2=$param2"); if( preg_match("/%3D/", $qs) ) { echo "query string is already urlencoded"; } - What if the source line is
%3and it is not actually driven? - andreymal - I think that if the urldecode is used for its intended purpose, then the string in any case will have at least one key pair = value - Kirill Korushkin
- fourProceeding from the fact that this question was asked at all, I am sure that the author does not use urlencode as intended :) - Andreymal
- I agree, but it became interesting to myself) - Kirill Korushkin
- oneAnd, by the way, it's still not
%3, but%3Dis andreymal
|
a%20b, I can bear it in mind with the percentagea%20b, and nifiga not with the spaceab- andreymal