| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::ClearFields; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1852
|
use Moose; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
13
|
|
|
4
|
2
|
|
|
2
|
|
8945
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.02'; # VERSION |
|
7
|
|
|
|
|
|
|
# ABSTRACT: mtpolicyd plugin to unset session variables |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Plugin'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
190
|
use Mail::MtPolicyd::Plugin::Result; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
736
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'fields' => ( is => 'rw', isa => 'Maybe[Str]' ); |
|
15
|
|
|
|
|
|
|
has 'fields_prefix' => ( is => 'rw', isa => 'Maybe[Str]' ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub clear_fields { |
|
18
|
1
|
|
|
1
|
0
|
1
|
my ( $self, $r ) = @_; |
|
19
|
1
|
|
|
|
|
27
|
my @fields = split(/\s*,\s*/, $self->fields); |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
10
|
$self->log($r, 'clearing fields '.join(', ', @fields)); |
|
22
|
1
|
|
|
|
|
2
|
foreach my $field ( @fields ) { |
|
23
|
1
|
|
|
|
|
34
|
delete $r->session->{$field}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
1
|
|
|
|
|
2
|
return; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub clear_fields_prefix { |
|
29
|
1
|
|
|
1
|
0
|
1
|
my ( $self, $r ) = @_; |
|
30
|
1
|
|
|
|
|
27
|
my @prefixes = split(/\s*,\s*/, $self->fields_prefix); |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
5
|
$self->log($r, 'clearing fields with prefixes: '.join(', ', @prefixes)); |
|
33
|
1
|
|
|
|
|
2
|
foreach my $prefix ( @prefixes ) { |
|
34
|
2
|
|
|
|
|
3
|
foreach my $field ( keys %{$r->session} ) { |
|
|
2
|
|
|
|
|
52
|
|
|
35
|
13
|
100
|
|
|
|
44
|
if( $field !~ /^\Q$prefix\E/) { |
|
36
|
8
|
|
|
|
|
9
|
next; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
5
|
|
|
|
|
112
|
delete $r->session->{$field}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
1
|
|
|
|
|
2
|
return; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub run { |
|
45
|
1
|
|
|
1
|
1
|
338
|
my ( $self, $r ) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
50
|
|
|
|
35
|
if( defined $self->fields) { |
|
48
|
1
|
|
|
|
|
4
|
$self->clear_fields( $r ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
1
|
50
|
|
|
|
29
|
if( defined $self->fields_prefix) { |
|
51
|
1
|
|
|
|
|
3
|
$self->clear_fields_prefix( $r ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
4
|
return; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Mail::MtPolicyd::Plugin::ClearFields - mtpolicyd plugin to unset session variables |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 2.02 |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This plugin could be used to reset some session variables. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 PARAMETERS |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item fields (default: empty) |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
A comma separated list of session variables to unset. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item fields_prefix (default: empty) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
A comma separated list of prefixes. |
|
90
|
|
|
|
|
|
|
All session variables with this prefixes will be unset. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
<Plugin cleanup> |
|
97
|
|
|
|
|
|
|
module = "ClearFields" |
|
98
|
|
|
|
|
|
|
fields = "spamhaus-rbl,spamhaus-dbl" |
|
99
|
|
|
|
|
|
|
</Plugin> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Will remove both fields from the session. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
<Plugin cleanup> |
|
104
|
|
|
|
|
|
|
module = "ClearFields" |
|
105
|
|
|
|
|
|
|
fields_prefix = "spamhaus-" |
|
106
|
|
|
|
|
|
|
</Plugin> |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Will also remove both fields and everything else starting with "spamhaus-" from the session. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This is free software, licensed under: |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |