Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts

    STRIP Script Tags

    I need something to completly replace any scripts tags found in a variable... there may be numerous instances within the variable of script tags if that makes a difference

    thanks
    IF I DID GOOD THROW ME A REP POINT

  • #2
    Regular Coder
    Join Date
    Jun 2008
    Location
    SE Wisconsin, US
    Posts
    222
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Check out this link at msdn.microsoft.com. This should help get you going. Regular expressions will work nicely for this.

    Hope that helps.
    Milwaukee Web Designer and SEO Milwaukee Firm specializing in ASP.Net, C#, VB.Net, SQL Server and Access.

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    LINQ to XML is a nice solution for that.

    If you only need to strip the tags, you could use LINQ to XML...

    XDocument doc = XDocument.Parse(html);
    doc.Elements("script").Remove();

    Don't forget about other attributes that can execute javascript....

    doc.Attributes("onclick").Remove();

    ...something like that.

    There are a lot of different ways for javascript to be executed though so it's tough to be completely thorough. I'm sure there are more robust solutions out there.

    http://blog.sonerdy.com

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Aside from the fact you are answering a post that is 17 months old, you are giving an ASP.NET answer and the question related to ASP. No, the two are not the same thing, at all.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •