Problems? Is your data what you think it is? | |
PerlMonks |
Re: Checking forms for JavaScriptby Cubes (Pilgrim) |
on Jul 24, 2001 at 02:13 UTC ( [id://99187]=note: print w/replies, xml ) | Need Help?? |
I'm not sure if there's any way to pick javascript code out of some random block of text without doing some serious linguistic analysis.
What's your objective here? I'm guessing you have some stuff from a web form that's going to go back onto a web page, and you don't want to allow any potentially nasty javascript. Based on that assumption... You could take the easy way out and just strip anything that looks like an HTML tag. Or you could strip out <script> tags, the string 'javascript:', and any html tag attributes that have to do with javascript (onClick, onMouseOver, etc.). Not being a javascript wiz, I'm sure I haven't covered everything, but this ought to give you a start. You might get more useful answers if you can post more details of what you're trying to accomplish with this code. Update: corrected para 3. Of course I meant strip out <script> tags
In Section
Seekers of Perl Wisdom
|
|