【发布时间】:2010-07-29 17:36:18
【问题描述】:
function validCleanHtml( $unclosedString )
{
preg_match_all( "/<([^\/]\w*)>/", $closedString = $unclosedString, $tags );
for ( $i = count( $tags[1] ) - 1; $i >= 0; $i-- )
{
$tag = $tags[1][$i];
if ( substr_count( $closedString, "</$tag>" ) < substr_count( $closedString, "<$tag>" ) )
$closedString .= "</$tag>";
}
$validTags = "<em><strong>";
$validClosedString = strip_tags( $closedString, $validTags );
return $validClosedString;
}
好的,我想要的是启用 2 个 html,em 和 strong,这对 xss 来说是安全的吗?如果不是,我们如何保护它?
【问题讨论】: