use strict; use Test::More; BEGIN { plan (tests => 17); use_ok('HTML::TagFilter'); } my $tf = HTML::TagFilter->new( log_rejects => 1, strip_comments => 0, echo => 0, ); my $tf2 = HTML::TagFilter->new( log_rejects => 0, strip_comments => 1, rubbish => 0, ); my $tf3 = HTML::TagFilter->new( allow => { p => { class=> [qw(lurid sombre plain)] }, }, ); my $tf4 = HTML::TagFilter->new( deny => { p => { any => [] }, a => { all => [] }, }, ); my $tf5 = HTML::TagFilter->new( skip_mailto_entification => 1, skip_ltgt_entification => 1, ); ok( $tf, 'tagfilter object configured and constructed' ); is( $tf->filter("

testing

"), "

testing

", "default tag allowance" ); is( $tf->filter("testing"), "testing", "default tag denial"); is( $tf->filter(qq|

testing

|), "

testing

", "default attribute denial"); is( $tf->filter(qq|

testing

|), "

testing

", "default value denial"); $tf->clear_rules(); is( $tf->filter(qq|

testing

|), "testing", "rules cleared: everything stripped"); my $report = $tf->report; ok( $report =~ /<p>/, "removal logging"); my $error = $tf2->error; ok( $error =~ /rubbish/, "error report" ); is( $tf->filter("

testing

"), "testing<!--hey-->", "comment permitted, < > escaped"); is( $tf2->filter("

testing

"), "

testing

", "comment deleted" ); is( $tf2->report, undef, "report properly empty"); is( $tf3->filter(qq|

testing

|), qq|

testing

|, "manually permitted attribute remains: others removed."); is( $tf4->filter(qq|testing|), qq|testing|, "manually forbidden tag removed: others permitted" ); is( $tf4->filter(qq|

testing

|), qq|

testing

|, "manually forbidden attribute removed: others permitted" ); is( $tf2->filter(qq|4|), qq|4|, "attribute order preserved" ); is( $tf2->filter(qq|

oops

|), qq|

oops

|, "none is magic" );