How to filter Html,js,css code

Source: Internet
Author: User
Tags filter return

The following is a reference fragment:
The following are the referenced contents:
#region///Filter HTML,JS,CSS code
<summary>
Filter HTML,JS,CSS Code
</summary>
<param name= "HTML" > Parameters passed in </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, ""); Filtration <script></script> Labeling
html = regex2. Replace (HTML, ""); Filter Href=javascript: (<A>) Properties
html = regex3. Replace (HTML, "_disibledevent="); Filter other controls on ... Event
html = regex4. Replace (HTML, ""); Filter iframe
html = regex5. Replace (HTML, ""); Filtration Frameset
html = regex6. Replace (HTML, ""); Filtration Frameset
html = regex7. Replace (HTML, ""); Filtration Frameset
html = regex8. Replace (HTML, ""); Filtration 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" > Parameters passed in </param>
<returns></returns>
public static string Inputstr (string html)
{
html = HTML. Replace (@ "\]+\>", "");
html = HTML. Replace (@ "<p>", "");
html = HTML. Replace (@ "</p>", "");
return HTML;
}
#endregion

<summary>
Intercepting strings
</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;
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.