That will not adequately strip javascript.
Slashdot|MS Security: On A Path As Clear As It Is Reliable pointed me to Expert hacks Hotmail in 1 line of code which in turn pointed me here, which reveals that STYLE tags in netscape will execute the stuff enclosed in style tags as javascript, if the TYPE attribute of the style tag is "application/x-javascript".
Your code: 56: $str=~s/<script[^>]*>.*?<\/script[^>]*>//igs if $$USER{jsoff};
My addition (you're welcome to improve):
#!/usr/bin/perl -w
use strict;
my $string = q|<STYLE TYPE="application/x-javascript" Language='Englis
+h' TYPE="application/x-javascript">|;
printf "%s\n", $string;
$string =~ s¡<STYLE\s([^>]*)>¡
{
my $trt = $1;
# $trt =~ s!type=\S+?(\s|"|')!TYPE="text/css"!igs;
$trt =~ s!type=\S+?[ '"]!TYPE="text/css"!igs;
qq(<STYLE $trt>)
}¡eigsx;
printf "%s\n", $string;
Also evil are
object, applet and embed tags (i'm sure there are others).
update: a slightly smarter version
#!/usr/bin/perl -w
use strict;
my $string = q|<STYLE TYPE="application/x-javascript" Language='Englis
+h' TYPE="application/x-javascript">|;
printf "%s\n", $string;
$string =~ s¡<STYLE\s([^>]*>)¡
{
my $trt = $1;
# $trt =~ s!type=\S+?(\s|"|')!TYPE="text/css"!igs;
$trt =~ s!type=\S+?[ '">]!TYPE="text/css"!igs;
$trt .= '>' if substr($trt,-1,1) ne '>';
qq(<STYLE $trt)
}¡eigsx;
printf "%s\n", $string;
update: OeufMayo says in the cb, what about:
<a href="#" onClick="alert('evil javascript here');">
Well I thought htmlScreen would take care of it, but you do
override the filter
$str.=htmlcode('parselinks','doctext,override');
... in parselinks ...
$text=htmlScreen($text,$APPROVED) unless $overridefilter eq "override"
+;
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.