1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/usr/bin/perl -T
use strict;
use warnings;
use lib '.'; use lib 't';
use SATest; sa_t_init("html_nested_anchors");
use Mail::SpamAssassin::HTML;
use Test::More;
my @tests = (
{
html => '<a href="#one">foo<a href="#two">bar</a>baz</a>',
uris => {
'#one' => {
types => { 'a' => 1 },
anchor_text => ['foobarbaz'],
},
'#two' => {
types => { 'a' => 1 },
anchor_text => ['bar'],
}
}
},
{
html => '<a href="#one">foo<a href="#one">bar</a>baz</a>',
uris => {
'#one' => {
types => { 'a' => 1 },
anchor_text => ['foobarbaz', 'bar'],
},
}
},
);
plan tests => scalar @tests;
foreach my $test (@tests) {
my $html = $test->{html};
my $html_obj = Mail::SpamAssassin::HTML->new(0, 0);
$html_obj->parse($html);
my $uris = $html_obj->{results}->{uri_detail};
is_deeply($uris, $test->{uris}, "URI details match for HTML: $html");
}
|