Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-02-2008, 01:58 AM   PM User | #1
scrupul0us
Regular Coder

 
Join Date: Sep 2004
Posts: 230
Thanks: 1
Thanked 0 Times in 0 Posts
scrupul0us can only hope to improve
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
scrupul0us is offline   Reply With Quote
Old 07-02-2008, 03:40 AM   PM User | #2
demtron
Regular Coder

 
Join Date: Jun 2008
Location: SE Wisconsin, US
Posts: 222
Thanks: 1
Thanked 20 Times in 20 Posts
demtron is on a distinguished road
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.
demtron is offline   Reply With Quote
Old 11-18-2009, 06:02 PM   PM User | #3
BrandonJoyce
New to the CF scene

 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
BrandonJoyce is an unknown quantity at this point
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
BrandonJoyce is offline   Reply With Quote
Old 11-18-2009, 07:19 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,172
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:11 PM.


Advertisement
Log in to turn off these ads.