rt 4.0.6
[freeside.git] / rt / t / web / scrub.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use RT::Test nodb => 1, tests => 6;
6 use RT::Interface::Web; # This gets us HTML::Mason::Commands
7 use Test::LongString;
8
9 {
10     my $html = 'This is a test of <span style="color: rgb(255, 0, 0); ">color</span> and <span style="font-size: 18px; "><span style="font-family: Georgia, serif; ">font</span></span> and <em><u><strike><strong>boldness</strong></strike></u></em>.';
11     is_string(scrub_html($html), $html, "CKEditor produced HTML sails through");
12 }
13
14 {
15     my $html = '<p style="text-align: right; ">
16         And <span style="color: rgb(255, 0, 0); "><span style="font-size: 16px; "><span style="font-family: Georgia, serif; ">alignment with color</span></span></span>?</p>';
17     is_string(scrub_html($html), $html, "CKEditor produced HTML sails through");
18 }
19
20 {
21     my $html = 'This is a test of <span style="color: rgb(255, 0, 0); content: url(/Nasty/URL);">color</span> and <span style="font-size: 18px; "><span style="font-family: Georgia, serif; ">font</span></span> and <em><u><strike><strong>boldness</strong></strike></u></em>.';
22     my $expected = 'This is a test of <span>color</span> and <span style="font-size: 18px; "><span style="font-family: Georgia, serif; ">font</span></span> and <em><u><strike><strong>boldness</strong></strike></u></em>.';
23     is_string(scrub_html($html), $expected, "nasty CSS not allowed through");
24 }
25
26 {
27     my $html = 'Let\'s add some <span style="color: blue; font-family: Georgia">color</span> up in <span style="color: #DEADBE">here</span>.';
28     is_string(scrub_html($html), $html, "multiple props and color specs allowed");
29 }
30
31 {
32     my $html = q[<span lang=EN-US style='font-family:"Century Gothic","sans-serif";'>oh hai I'm some text</span>];
33     my $expected = q[<span lang="EN-US" style="font-family:&quot;Century Gothic&quot;,&quot;sans-serif&quot;;">oh hai I'm some text</span>];
34     is_string(scrub_html($html), $expected, "font lists");
35 }
36
37 {
38     my $html = q[<span lang=EN-US style='font-size:7.5pt;font-family:"Century Gothic","sans-serif";color:#666666;mso-fareast-language:IT'>oh hai I'm some text</span>];
39     my $expected = q[<span lang="EN-US" style="font-size:7.5pt;font-family:&quot;Century Gothic&quot;,&quot;sans-serif&quot;;color:#666666;mso-fareast-language:IT">oh hai I'm some text</span>];
40     is_string(scrub_html($html), $expected, "outlook html");
41 }
42
43 sub scrub_html {
44     return HTML::Mason::Commands::ScrubHTML(shift);
45 }
46