过滤方法
private String HtmlCode(string TString)
{
if (TString != null)
{
TString = TString.Replace("\r", "<br>");
//TString = TString.Replace(" ", " ");
TString = TString.Replace("<script>", "<script>");
TString = TString.Replace("</script>", "</script>");
TString = TString.Replace("<script language=javascript>", "<script language=javascript></script>");
//TString = TString.Replace(" ", " ");
//System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<script[sS]+< /script *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[sS]*script *:", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" on[sS]*=", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[sS]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[sS]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//TString = regex1.Replace(TString, ""); //过滤< script>< /script>标记
//TString = regex2.Replace("", TString); //过滤href=javascript: (< A>) 属性
//TString = regex3.Replace(" _disibledevent=",TString); //过滤其它控件的on...事件
//TString = regex4.Replace("", TString); //过滤iframe
//TString = regex5.Replace("", TString); //过滤frameset
//TString = TString.Replace("", " ");
return TString;
}
else
{
return TString = "无内容";
}
}