导航:首页 > 净水问答 > net访问过滤路径

net访问过滤路径

发布时间:2023-08-26 09:17:33

⑴ asp.net如何过滤掉html代码

Asp.net中如何过滤html,js,css代码
以下为引用的内容:

#region/// 过滤html,js,css代码
/// <summary>
/// 过滤html,js,css代码
/// </summary>
/// <param name="html">参数传入</param>
/// <returns></returns>
public static string CheckStr(string html)
{
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<script[\s\S]+</script *>", 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(@"<iframe[\s\S]+</iframe *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[\s\S]+</frameset *>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"\<img[^\>]+\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"</p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"<p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = regex1.Replace(html, ""); //过滤<script></script>标记
html = regex2.Replace(html, ""); //过滤href=javascript: (<A>) 属性
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("</strong>", "");
html = html.Replace("<strong>", "");
return html;
}
#endregion
#region /// 过滤p /p代码
/// <summary>
/// 过滤p /p代码
/// </summary>
/// <param name="html">参数传入</param>
/// <returns></returns>
public static string InputStr(string html)
{
html = html.Replace(@"\<img[^\>]+\>", "");
html = html.Replace(@"<p>", "");
html = html.Replace(@"</p>", "");
return html;
}
#endregion

阅读全文

与net访问过滤路径相关的资料

热点内容
净水机有一个小孔有水怎么回事 浏览:139
污水池爆气管用什么方法疏通 浏览:805
创维后置活性炭滤芯怎么样 浏览:869
化工污水清理一般多少钱 浏览:837
重庆涪陵污水处理厂工资怎么样 浏览:942
MBR超滤膜清洗 浏览:610
鱼缸用树脂摆件可以么 浏览:238
什么净水远 浏览:416
从四川回辽宁用隔离吗 浏览:223
溢泰净水器和汉斯顿净水器哪个好 浏览:368
景观鱼池过滤 浏览:639
纳滤能拦截苯环 浏览:520
饮水机的水热水能烧大概是多少度 浏览:669
等离子去疤痕好不好 浏览:197
江西废水处理氨氮超标如何处理 浏览:988
小米净水器更换滤芯怎么弄 浏览:958
纯水离子交换树脂是危废吗 浏览:100
三星空调滤芯怎么拆卸 浏览:650
全自动污水提升器购买 浏览:331
超滤和反渗透膜的区别 浏览:469