# -*-perl-*-
use strict;
use Test::More 'no_plan';
use lib "$ENV{LJHOME}/cgi-bin";
require 'ljlib.pl';
require 'cleanhtml.pl';
use HTMLCleaner;
my $orig_post;
my $clean_post;
my $clean = sub {
$clean_post = $orig_post;
LJ::CleanHTML::clean_event(\$clean_post, {tablecheck => 1});
};
# VALID: standard table
$orig_post = "
";
$clean->();
ok($orig_post eq $clean_post, "Table okay if all tags are closed");
# VALID: table without closing tr/td tags
$orig_post = "";
$clean->();
ok($orig_post eq $clean_post, "Table okay if td and tr tags aren't closed");
# INVALID: table without opening table tag, should escape all tags
$orig_post = "| Cell 1 | Cell 2 |
| Cell 3 | Cell 4 |
";
$clean->();
ok($clean_post !~ '";
$clean->();
ok($clean_post !~ '";
$clean->();
ok($clean_post !~ '";
$clean->();
ok($clean_post !~ '";
$clean->();
ok($clean_post !~ 'Cell 1 | Cell 2 | Cell 3 | Cell 4 | ";
$clean->();
ok($clean_post !~ ' | | foo |
";
$clean->();
ok($clean_post eq ""
|| $clean_post eq "", "Fixed tbody -- optional");