# -*-perl-*- use strict; use Test::More 'no_plan'; use lib "$ENV{LJHOME}/cgi-bin"; require 'ljlib.pl'; require 'cleanhtml.pl'; use HTMLCleaner; my $lju_sys = LJ::ljuser("system"); my $fullurl = "http://lj.example/full.html"; my $clean = sub { my $raw = shift; my %opts = @_; LJ::CleanHTML::clean_event(\$raw, { cuturl => defined $opts{cuturl} ? $opts{cuturl} : $fullurl, }); return $raw; }; # old lj user tag is($clean->("some text more text"), "some text $lju_sys more text", "old lj user tag"); # testing tag maps to an lj user tag is($clean->("some text more text"), "some text $lju_sys more text", "lj comm= on a user"); # span ljuser is($clean->("[system]"), "[$lju_sys]", "span ljuser"); is($clean->("[bob system]"), "[$lju_sys]", "span ljuser with junk inside"); # old lj-ut is($clean->("And a cut:foooooooooooooo"), "And a cut:Read more... )", "old lj-cut"); is($clean->("And a cut:foooooooooooooo"), "And a cut:foo )", "old lj-cut w/ text"); # new lj-cut is($clean->(qq{New cut:
baaaaaaaaaarrrrr
}), qq{New cut:
Read more... )
}, "new lj-cut w/ div"); is($clean->(qq{New cut:
baaaaaaaaaarrrrr
}), qq{New cut:
This is my div cut )
}, "new lj-cut w/ div w/ text"); # nested div cuts is($clean->(qq{Nested:
baaaaaaaaaa
I AM RED
arrrrrr
}), qq{Nested:
Nested )
}, "nested div cuts"); is($clean->(qq{Nested:
baaaaaaaaaa
I AM RED
arrrrrr
}, cuturl => ""), qq{Nested:
baaaaaaaaaa
I AM RED
arrrrrr
}, "nested div cuts, expanded"); is($clean->(qq{Nested:
baaaaaaaaaa
I AM RED
arrrrrr
}, cuturl => ""), qq{Nested:
baaaaaaaaaa
I AM RED
arrrrrr
</div>}, "nested div cuts, expanded, user's extra close div"); is($clean->(qq{Nested:
fin}, cuturl => ""), qq{Nested:
fin}, "nested div cuts, more"); # MORE TO TEST: # -- cutdisabled flag? # -- ... ?