重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

.net过滤特定代码

#region/// 过滤html,js,css代码
/// 


/// 过滤html,js,css代码
/// 

/// 参数传入
/// 
public static string CheckStr(string html)
{
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[\s\S]*script *:", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" no[\s\S]*=", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"\]+\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"

", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"

", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = regex1.Replace(html, ""); //过滤标记
html = regex2.Replace(html, ""); //过滤javascript: () 属性
html = regex3.Replace(html, " _disibledevent="); //过滤其它控件的on...事件
html = regex4.Replace(html, ""); //过滤iframe
html = regex5.Replace(html, ""); //过滤frameset
html = regex6.Replace(html, ""); //过滤frameset
html = regex7.Replace(html, ""); //过滤frameset
html = regex8.Replace(html, ""); //过滤frameset
html = regex9.Replace(html, "");
html = html.Replace(" ", "");
html = html.Replace("", "");
html = html.Replace("", "");
return html;
}
#endregion
#region /// 过滤p /p代码
/// 


/// 过滤p /p代码
/// 

/// 参数传入
/// 
public static string InputStr(string html)
{
html = html.Replace(@"\]+\>", "");
html = html.Replace(@"

", "");
html = html.Replace(@"

", "");
return html;
}
#endregion

在城关等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、网站建设、外贸网站建设 网站设计制作定制网站制作,公司网站建设,企业网站建设,品牌网站制作,营销型网站,外贸网站制作,城关网站建设费用合理。


/// 


/// 截取字符串
/// 

/// 
/// 
/// 
protected string GetLength(string str, int length)
{
string strR = str;
if (str.Length > length)
{
strR = str.Substring(0, length) + "...";
}
return strR;
}

 


分享题目:.net过滤特定代码
当前URL:http://cqcxhl.com/article/jheoes.html
在线咨询
服务热线
服务热线:028-86922220
TOP