2012-06-29 50 views
0

當我將用戶輸入數據插入到我使用的mysql數據庫中時,mysql_real_escape_string。輸入數據包含bbcode例如[img][/img]htmlentities或htmlspecialchars或stripslashes?哪一個使用?

下面是輸出html時的一行。

$information = $this->bbcode(stripslashes($this->swearfilter($row['information'])),1); 
    echo $information; 

關於這個例子,這是正確的方式,以防止XSS攻擊或我使用htmlspecialchars($var,ENT_QUOTES)htmlentities

回答

2

使用htmlspecialchars()防止XSS攻擊

0
$message = preg_replace('#\[img\](.*?)\[/img\]#', '<img src="$1" />', $message); 

Prevent XSS Attacks

相關問題