From: Marius Gavrilescu Date: Wed, 15 Apr 2015 15:47:26 +0000 (+0300) Subject: Use Subresource Integrity X-Git-Url: http://git.ieval.ro/?p=plack-app-gruntmaster.git;a=commitdiff_plain;h=7e8f9a5c2eaddad49aebc6911706533ef64db1eb Use Subresource Integrity --- diff --git a/make_static.PL b/make_static.PL index 10532b9..758efc1 100644 --- a/make_static.PL +++ b/make_static.PL @@ -5,8 +5,9 @@ use warnings; use CSS::Minifier::XS qw//; use JavaScript::Minifier::XS qw//; +use Digest::SHA qw/sha256_base64/; use IO::Compress::Gzip qw/gzip/; -use File::Slurp qw/read_file write_file/; +use File::Slurp qw/read_file write_file edit_file_lines/; mkdir 'static'; mkdir 'static/css'; @@ -57,3 +58,10 @@ for () { last } } + +edit_file_lines { + my ($file) = m,(static.*\.(?:css|js)),; + return unless $file; + my $hash = sha256_base64 scalar read_file $file; + s/integrity=".*"/integrity="sha256-$hash="/; +} 'tmpl/skel.en' diff --git a/tmpl/skel.en b/tmpl/skel.en index 3006e14..459d37b 100644 --- a/tmpl/skel.en +++ b/tmpl/skel.en @@ -3,10 +3,10 @@ - - - - + + + +