| 以下是引用片段 : 以下为引用的内容 : #region /// 过滤 html, JS, CSS 代码 /// <summary> /// 过滤 HTML, JS, CSS 代码 /// </summary> /// <paramname = "html"> 参数传入 </param> /// <returns> </returns> publicstaticstringcheckstr (Stringhtml) { System.text.regularexpressions.regexRegex1 = newSystem.text.regularexPressions.regex (@"<script [/s/s]+</script*>", system.text.regularexpressions.regexoptions.ignorecase); System.Text.regularexPressions.RegexRegex2 = newSystem.text.regularexPressions.regex (@"href*=*[/s/s]*script*:", system.text.regularexpressions.regexoptions.ignorecase); System.text.regularexpressions.regexRegex3 = newSystem.text.regularexPressions.regex (@"no [/s/s]*=", system.text.regularexpressions.regexoptions.ignorecase); System.Text.RegularexPressions.regexRegex4 = newSystem.text.regularexPressions.regex (@"<iframe [/s/s]+</iframe*>", system.text.regularexpressions.regexoptions.ignorecase); System.text.regularexpressions.regexRegex5 = newSystem.text.regularexPressions.regex (@"<frameset [/s/s]+</frameset*>", system.text.regularexpressions.regexoptions.ignorecase); System.text.regularexPressions.regexRegex6 = newSystem.text.regularexPressions.regex (@"/<img [^/>]+/>", system.text.regularexpressions.regexoptions.ignorecase); System.text.regularexPressions.regexRegex7 = newSystem.text.regularexPressions.regex (@"</p>", system.text.regularexpressions.regexoptions.ignorecase); System.text.regularexpressions.regexRegex8 = newSystem.text.regularexPressions.regex (@"<p>", system.text.regularexpressions.regexoptions.ignorecase); System.text.regularexPressions.regexRegex9 = newSystem.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>", ""); returnhtml; } #endregion #region /// 过滤 P/P 代码 /// <summary> /// 过滤 P/P 代码 /// </summary> /// <paramname = "html"> 参数传入 </param> /// <returns> </returns> publicstaticstringinputstr (Stringhtml) { html = html.replace (@"/<img [^/>]+/>", ""); html = html.replace (@"<p>", ""); html = html.replace (@"</p>", ""); returnhtml; } #endregion /// <summary> /// 截取字符串 /// </summary> /// <paramname = "str"> </param> /// <paramname = "length"> </param> /// <returns> </returns> ProtectectringgetLength (Stringstr, Intlength) { StringStrr = str; if (str.length> длина) { strr = str.substring (0, длина)+"..."; } returnstrr; } |