当我将用户输入数据插入到mysql数据库中时,我使用mysql_real_escape_string。输入数据包含bbcode,例如[img][/img]。
下面是输出html的时间行。
$information = $this->bbcode(stripslashes($this->swearfilter($row['information'])),1);
echo $information;关于这个例子,这是防止XSS攻击的正确方法,还是我应该使用htmlspecialchars($var,ENT_QUOTES)或htmlentities
发布于 2012-06-29 17:02:13
使用htmlspecialchars()防止XSS攻击
发布于 2012-06-29 17:05:13
$message = preg_replace('#\[img\](.*?)\[/img\]#', '<img src="$1" />', $message); Prevent XSS Attacks
https://stackoverflow.com/questions/11258870
复制相似问题