PHP offers parsing methods to protect against PHP / SQL code injection (i.e. mysql_real_escape_string()). This does not apply to HTML / CSS / JavaScript. Why?
First: The sole purpose of HTML / CSS / Javascript is to display information. To a large extent, you can accept certain HTML elements or reject them depending on your requirements.
-: - HTML/CSS/JS ( ) HTML. .
. , . , , BBCdode, . "" BBCode, .
BBCode- - ( ). WISIGIG / , , .
. HTML .
1
, , . , , HTML-, 100%.
, , , :
- , , PHP
strip_tags(). - ()
PHP
preg_replace() .
$string = "put some very dirty HTML here.";
$string = strip_tags($string, '<p><a><span><h1><li><ul><br>');
$string = preg_replace("/<([b-z][b-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $string);
echo $string;
.
note: , href="". , [b-z][B-Z].