# 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 href = 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;
}
# 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 href = 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;
}