2016-05-30 115 views
0

我們正在添加用戶可添加的可嵌入內容。這開闢了很多的漏洞,我想開始最大限度地減少潛在的破壞。確保給定的字符串包含iframe或object標籤

首先,我需要確保可嵌入的字符串或者或<object>開始,以</iframe></object>

發現這個結尾: https://stackoverflow.com/questions/28118798/how-can-i-check-a-string-is-iframe-tag-by-php-functions

,但我需要重寫一遍,我不知所措。

$string = '<iframe src="sourceurl"></iframe>'; 
$test = strpos($string,'<iframe'); 
if (!empty($test)) { 
    echo 'That has an iframe!!'; 
} else { 
    echo 'There's no iframe in there...'; 
} 

我該如何攻擊?在旁註中,我應該只是廢棄物體嵌入嗎?他們覺得非常脆弱..

+1

看看http://php.net/manual/de/function.strip-tags.php – donald123

+0

是你的''string''變量是否只包含**''