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
|
|
3895
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
5
|
|
|
|
|
25
|
|
|
5
|
|
|
|
|
39
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1133
|
use Carp qw(croak); |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
1559
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub register { |
12
|
5
|
|
|
5
|
1
|
253
|
my ($self, $app, $config) = @_; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
100
|
|
|
32
|
my $value = $config->{content} // 'no-referrer'; |
15
|
|
|
|
|
|
|
|
16
|
5
|
100
|
100
|
|
|
27
|
if ( $value ne 'no-referrer' && $value ne 'same-origin' ) { |
17
|
1
|
|
|
|
|
208
|
croak 'invalid value: ' . $value; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$app->hook( |
21
|
|
|
|
|
|
|
after_render => sub { |
22
|
4
|
|
|
4
|
|
91466
|
my ($c, $content, $format) = @_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
50
|
|
|
|
20
|
return if !$format; |
25
|
4
|
50
|
33
|
|
|
22
|
return if $format ne 'html' && $format ne 'css'; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
38
|
$$content =~ s{\K}{}; |
28
|
|
|
|
|
|
|
} |
29
|
4
|
|
|
|
|
44
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__END__ |