Skip to content

Commit af86478

Browse files
committed
fix inline script test to only care about javascript
script tags can be used for things other than inline scripts, so only care about script tags that don't have a type, or have a javascript type.
1 parent 8d350a1 commit af86478

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

t/html.t

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use Path::Tiny qw( path );
88

99
# files that have inline <script> tags
1010
my %skip = map { $_ => 1 } (
11-
'root/account/profile.html', 'root/account/turing.html',
12-
'root/author.html', 'root/wrapper.html',
13-
'root/about/contributors.html', 'root/inc/favorite.html',
11+
'root/about/contributors.html', 'root/account/profile.html',
12+
'root/account/turing.html', 'root/wrapper.html',
1413
);
1514

1615
my $rule = Path::Iterator::Rule->new;
@@ -19,7 +18,13 @@ for my $file ( $rule->all('root') ) {
1918
my $html = path($file)->slurp_utf8;
2019
ok $html !~ /<style>/, "no inline style in $file";
2120
if ( not $skip{$file} ) {
22-
ok $html !~ /<script[>\s]/, "no inline script in $file";
21+
my @script_tags = $html =~ /<script\b([^>]*)>/;
22+
my @js = grep {
23+
/\btype="([^"]*)"/
24+
? ( $1 =~ /(?:j|java|emca)script/ ? 1 : () )
25+
: 1
26+
} @script_tags;
27+
ok !@js, "no inline script in $file";
2328
}
2429
}
2530

0 commit comments

Comments
 (0)