2016-05-30 109 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''变量是否只包含**''