fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / scrub.t
1 use strict;
2 use warnings;
3
4 use RT::Test nodb => 1, tests => 6;
5 use RT::Interface::Web; # This gets us HTML::Mason::Commands
6 use Test::LongString;
7
8 {
9     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>.';
10     is_string(scrub_html($html), $html, "CKEditor produced HTML sails through");
11 }
12
13 {
14     my $html = '<p style="text-align: right; ">
15         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>';
16     is_string(scrub_html($html), $html, "CKEditor produced HTML sails through");
17 }
18
19 {
20     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>.';
21     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>.';
22     is_string(scrub_html($html), $expected, "nasty CSS not allowed through");
23 }
24
25 {
26     my $html = 'Let\'s add some <span style="color: blue; font-family: Georgia">color</span> up in <span style="color: #DEADBE">here</span>.';
27     is_string(scrub_html($html), $html, "multiple props and color specs allowed");
28 }
29
30 {
31     my $html = q[<span lang=EN-US style='font-family:"Century Gothic","sans-serif";'>oh hai I'm some text</span>];
32     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>];
33     is_string(scrub_html($html), $expected, "font lists");
34 }
35
36 {
37     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>];
38     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>];
39     is_string(scrub_html($html), $expected, "outlook html");
40 }
41
42 sub scrub_html {
43     return HTML::Mason::Commands::ScrubHTML(shift);
44 }
45