test};
$clean_comment = qq{
test
};
$clean->();
ok( $orig_comment eq $clean_comment, "Closing div inserted." );
$orig_comment = qq{
test};
$clean_comment = qq{
test};
$clean->();
ok( $orig_comment eq $clean_comment, "Bad open/closes fixed." );
$orig_comment = qq{
};
$clean_comment = qq{
};
$clean->();
ok( $orig_comment eq $clean_comment, "Aggressively close things." );
$orig_comment = qq{
};
$clean_comment = qq{
};
$clean->();
ok( $orig_comment eq $clean_comment, "Aggressive close with eaten extra close." );
note("Remove absolute sizes when logged out");
{
$orig_comment = qq{foo};
$clean_comment = qq{foo};
$clean->( { anon_comment => 1 } );
is( $orig_comment, $clean_comment, "Retain relative font sizes" );
$orig_comment = qq{foo};
$clean_comment = qq{foo};
$clean->( { anon_comment => 1 } );
is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
$orig_comment = qq{foo};
$clean_comment = qq{foo};
$clean->( { anon_comment => 1 } );
is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
}
note("Don't remove absolute sizes when logged in");
{
$orig_comment = qq{foo};
$clean_comment = $orig_comment;
$clean->();
is( $orig_comment, $clean_comment, "Retain relative font sizes" );
$orig_comment = qq{foo};
$clean_comment = $orig_comment;
$clean->();
is( $orig_comment, $clean_comment, "Retain absolute font sizes" );
$orig_comment = qq{foo};
$clean_comment = $orig_comment;
$clean->();
is( $orig_comment, $clean_comment, "Retain absolute font sizes" );
}
# remove background urls from logged out users
$orig_comment = qq{};
$clean_comment =
qq{<\\/span>};
$clean->();
ok( $orig_comment =~ /^$clean_comment$/, "Background URL not cleaned: logged-in user" );
$orig_comment = qq{};
$clean_comment = qq{<\\/span>};
$clean->( { anon_comment => 1 } );
ok( $orig_comment =~ /^$clean_comment$/, "Background URL removed: anonymous comment" );
$orig_comment = qq{pre post};
$clean_comment = qq{pre post (asdf)};
$clean->( { anon_comment => 1 } );
is( $orig_comment, $clean_comment, "Full href bold escape" );
$orig_comment = qq{pre post};
$clean_comment = qq{pre post ()};
$clean->( { anon_comment => 1 } );
is( $orig_comment, $clean_comment, "Empty href bold escape" );
# another table exploit involving a tags.
$orig_comment = q{};
$clean_comment = q{ (mailto:blah@blah.com)};
$clean->( { anon_comment => 1 } );
is( $orig_comment, $clean_comment, "Anonymous comment bold escape" );
note("various allowed/disallowed tags");
{
$orig_comment = qq{abc};
$clean_comment = qq{abc};
$clean->();
is( $orig_comment, $clean_comment, "em tag allowed" );
$orig_comment = qq{};
$clean_comment = qq{abc};
$clean->();
is( $orig_comment, $clean_comment, "marquee tag not allowed" );
$orig_comment = qq{};
$clean_comment = qq{abc};
$clean->();
is( $orig_comment, $clean_comment, "blink tag not allowed" );
}
1;