| : : #Region /// 过滤 HTML, JS, CSS 代码 /// <résumé> /// 过滤 HTML, JS, CSS 代码 /// </summary> /// <paramname = "html"> 参数传入 </ param> /// <retourne> </ retourne> publicStaticStringChecktr (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 (@ "Non [/ 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, ""); // 过滤 <cript> </cript> 标记 html = regex2.replace (html, ""); // 过滤 href = javascript :( <a>) 属性 html = regex3.replace (html, "_ dissiblevent ="); // 过滤其它控件的 过滤其它控件的 过滤其它控件的 过滤其它控件的 过滤其它控件的 事件 事件 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 代码 /// <résumé> /// 过滤 P / P 代码 /// </summary> /// <paramname = "html"> 参数传入 </ param> /// <retourne> </ retourne> publicStaticStringInputstr (StringHtml) { html = html.replace (@ "/ <img [^ />] + />", ""); html = html.replace (@ "<p>", ""); html = html.replace (@ "</p>", ""); returnhtml; } #endregion /// <résumé> /// 截取字符串 /// </summary> /// <paramname = "str"> </ param> /// <paramname = "longueur"> </ param> /// <retourne> </ retourne> ProtectedStringGetLength (Stringstr, intLength) { Stringstrr = Str; if (str.length> longueur) { strr = str.substring (0, longueur) + "..."; } returnstrr; } |