Skip to content Skip to sidebar Skip to footer

Request Parameter Losing Plus Sign

I am editing a search form and trying to protect against special characters in the database. In the JSP search form, a (multiselect) dropdown allows users to select descriptions th

Solution 1:

+ means "space" in URLs. Replace it with %2B. You could do this just after composing descriptionsUrlAddition, for example.

descriptionsUrlAddition = descriptionsUrlAddition.replace("+", "%2B");

Solution 2:

For javascript you should use encodeURIComponent() or encodeuri(). For Example:

var uri = "fj74cvg+fd1==ee";
var res = encodeURIComponent(uri);

and res would be encoded to "fj74cvg%2Bfd1%3D%3Dee"

For php you can use urlencode(). For Example:

<?phpecho'<a href="mycgi?foo=', urlencode($userinput), '">';
?>

These functions will replace any special characters in the string to be used as part of the url.

Solution 3:

You should use in the front side The javascript encodeuri function to encode your parameters.

Post a Comment for "Request Parameter Losing Plus Sign"