line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::NoReferrer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: add meta tag to HTML output to define a referrer policy |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
4031
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
43
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1383
|
use Carp qw(croak); |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
1702
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub register { |
12
|
5
|
|
|
5
|
1
|
261
|
my ($self, $app, $config) = @_; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
100
|
|
|
39
|
my $value = $config->{content} // 'no-referrer'; |
15
|
|
|
|
|
|
|
|
16
|
5
|
100
|
100
|
|
|
38
|
if ( $value ne 'no-referrer' && $value ne 'same-origin' ) { |
17
|
1
|
|
|
|
|
323
|
croak 'invalid value: ' . $value; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$app->hook( |
21
|
|
|
|
|
|
|
after_render => sub { |
22
|
4
|
|
|
4
|
|
100050
|
my ($c, $content, $format) = @_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
50
|
|
|
|
27
|
return if !$format; |
25
|
4
|
50
|
33
|
|
|
27
|
return if $format ne 'html' && $format ne 'css'; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
43
|
$$content =~ s{\K}{}; |
28
|
|
|
|
|
|
|
} |
29
|
4
|
|
|
|
|
44
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |