6 use Test::More tests => 10;
10 use override_context_prefs;
11 use_ok('C4::Scrubber');
16 (@_) or return "#" x $max . "\n";
17 my $phrase = " " . shift() . " ";
18 my $half = "#" x (($max - length($phrase))/2);
19 return $half . $phrase . $half . "\n";
22 my ($scrubber,$html,$result,@types,$collapse);
24 @types = qw(comment tag);
26 <![CDATA[selfdestruct]]]>
27 <?php echo(" EVIL EVIL EVIL "); ?> <!-- COMMENT -->
28 <hr> <!-- TMPL_VAR NAME="password" -->
29 <style type="text/css">body{display:none;}</style>
30 <link media="screen" type="text/css" rev="stylesheet" rel="stylesheet" href="css.css">
31 <I FAKE="attribute" > I am ITALICS with fake="attribute" </I><br />
32 <em FAKE="attribute" > I am em with fake="attribute" </em><br />
33 <B> I am BOLD </B><br />
34 <span style="background-image: url(http://hackersite.cn/porno.jpg);"> I am a span w/ style. Bad style.</span>
35 <span> I am a span trying to inject a link: <a href="badlink.html"> link <a></span>
38 <A HREF="javascript:alert('OMG YOO R HACKED');">I am a link firing javascript.</A>
40 <A HREF="image/bigone.jpg" ONMOUSEOVER="alert('OMG YOO R HACKED');">
41 <IMG SRC="image/smallone.jpg" ALT="ONMOUSEOVER JAVASCRIPT">
44 At the end here, I actually have some regular text.
47 print pretty_line("Original HTML:"), $html, "\n", pretty_line();
48 $collapse and diag "Note: scrubber test output will have whitespace collapsed for readability\n";
49 ok($scrubber = C4::Scrubber->new(), "Constructor: C4::Scrubber->new()");
50 ok(printf("# scrubber settings: default %s, comment %s, process %s\n",
51 $scrubber->default(),$scrubber->comment(),$scrubber->process()),
52 "Outputting settings from scrubber object (type: [default])"
54 ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: [default])");
55 $collapse and $result =~ s/\s*\n\s*/\n/g;
56 print pretty_line('default'), $result, "\n", pretty_line();
59 ok($scrubber = C4::Scrubber->new($_), "Constructor: C4::Scrubber->new($_)");
60 ok(printf("# scrubber settings: default %s, comment %s, process %s\n",
61 $scrubber->default(),$scrubber->comment(),$scrubber->process()),
62 "Outputting settings from scrubber object (type: $_)"
64 ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: $_)");
65 $collapse and $result =~ s/\s*\n\s*/\n/g;
66 print pretty_line($_), $result, "\n", pretty_line();