Jump to content

Recommended Posts

$_SERVER['REQUEST_URI'] has the same issue as $_SERVER['PHP_SELF']. If the requested URL contains any xss scripting in it and you blindly echo it out on a page back to the browser without using htmlentities/htmlspecialchars on it, then the xss scripting in it will be sent as is to the browser.

 

You must always treat external data (anything received with the http request, even the URL itself) as dangerous and must filter/validate it if you are going to output it back to any browser.

 

To simplify the answer, if you want to output the value of $_SERVER['REQUEST_URI'] to the browser, you're completely safe if you reference it like this:

 

htmlspecialchars($_SERVER['REQUEST_URI'])

 

That will sanitize any characters that might be used to perform an XSS attack.

 

Keep in mind, if you're using a special character set, you need to define that in the function's call... check out the manual for more details: htmlspecialchars

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.