Jump to content

how can i block xss?


pcman

Recommended Posts

For intance

 

$mes = htmlspecialchars($_POST['message']);

echo htmlspecialchars_decode($mes);

 

Broken down:

 

Line 1: grabs the user's message, and if it contains the characters <html> it will return it as <html>

Line 2: takes the the users message "<html>", decodes the html special characters (hence the function name) and will return the message "<html>" without them being able to inject HTML, therefore you are virtually invunerable to that type of XSS.

 

Link to comment
https://forums.phpfreaks.com/topic/79816-how-can-i-block-xss/#findComment-404206
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.