# Region // filter html, js, and css code
/// <Summary>
/// Filter html, js, and css code
/// </Summary>
/// <Param name = "html"> parameter input </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 (@ "\ ] + \>", 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, ""); // filter <script> </script> tags
Html = regex2.Replace (html, ""); // filter javascript: (<A>) attributes
Html = regex3.Replace (html, "_ disibledevent ="); // filter events of other controls.
Html = regex4.Replace (html, ""); // filter iframe
Html = regex5.Replace (html, ""); // filter frameset
Html = regex6.Replace (html, ""); // filter frameset
Html = regex7.Replace (html, ""); // filter frameset
Html = regex8.Replace (html, ""); // filter frameset
Html = regex9.Replace (html ,"");
Html = html. Replace ("","");
Html = html. Replace ("</strong> ","");
Html = html. Replace ("<strong> ","");
Return html;
}
# Endregion
# Region // filter p/p code
/// <Summary>
/// Filter p/p code
/// </Summary>
/// <Param name = "html"> parameter input </param>
/// <Returns> </returns>
Public static string InputStr (string html)
{
Html = html. Replace (@ "\ ] + \> ","");
Html = html. Replace (@ "<p> ","");
Html = html. Replace (@ "</p> ","");
Return html;
}
# Endregion
/// <Summary>
/// Capture a string
/// </Summary>
/// <Param name = "str"> </param>
/// <Param name = "length"> </param>
/// <Returns> </returns>
Protected string GetLength (string str, int length)
{
String strR = str;
If (str. Length> length)
{
StrR = str. Substring (0, length) + "...";
}
Return strR;
}