line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::AuthenticationResults::Header; |
2
|
|
|
|
|
|
|
# ABSTRACT: Class modelling the Entire Authentication Results Header set |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require 5.008; |
5
|
28
|
|
|
28
|
|
307548
|
use strict; |
|
28
|
|
|
|
|
73
|
|
|
28
|
|
|
|
|
808
|
|
6
|
28
|
|
|
28
|
|
137
|
use warnings; |
|
28
|
|
|
|
|
53
|
|
|
28
|
|
|
|
|
995
|
|
7
|
|
|
|
|
|
|
our $VERSION = '2.20230112'; # VERSION |
8
|
28
|
|
|
28
|
|
141
|
use Carp; |
|
28
|
|
|
|
|
52
|
|
|
28
|
|
|
|
|
1565
|
|
9
|
|
|
|
|
|
|
|
10
|
28
|
|
|
28
|
|
11388
|
use Mail::AuthenticationResults::Header::AuthServID; |
|
28
|
|
|
|
|
86
|
|
|
28
|
|
|
|
|
1023
|
|
11
|
|
|
|
|
|
|
|
12
|
28
|
|
|
28
|
|
163
|
use base 'Mail::AuthenticationResults::Header::Base'; |
|
28
|
|
|
|
|
58
|
|
|
28
|
|
|
|
|
43809
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
296
|
|
|
296
|
|
2847
|
sub _HAS_VALUE{ return 1; } |
16
|
424
|
|
|
424
|
|
888
|
sub _HAS_CHILDREN{ return 1; } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _ALLOWED_CHILDREN { |
19
|
245
|
|
|
245
|
|
396
|
my ( $self, $child ) = @_; |
20
|
245
|
100
|
|
|
|
465
|
return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Comment'; |
21
|
236
|
100
|
|
|
|
676
|
return 1 if ref $child eq 'Mail::AuthenticationResults::Header::Entry'; |
22
|
6
|
|
|
|
|
59
|
return 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub set_indent_by { |
27
|
7
|
|
|
7
|
1
|
13
|
my ( $self, $value ) = @_; |
28
|
7
|
|
|
|
|
16
|
$self->{ 'indent_by' } = $value; |
29
|
7
|
|
|
|
|
22
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub indent_by { |
34
|
290
|
|
|
290
|
1
|
436
|
my ( $self ) = @_; |
35
|
290
|
100
|
|
|
|
729
|
return 4 if ! defined $self->{ 'indent_by' }; #5.8 |
36
|
114
|
|
|
|
|
224
|
return $self->{ 'indent_by'}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub set_indent_on { |
41
|
10
|
|
|
10
|
1
|
23
|
my ( $self, $type ) = @_; |
42
|
10
|
|
|
|
|
26
|
$self->{ 'indent_type_' . $type } = 1; |
43
|
10
|
|
|
|
|
12
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub clear_indent_on { |
48
|
20
|
|
|
20
|
1
|
52
|
my ( $self, $type ) = @_; |
49
|
20
|
|
|
|
|
55
|
$self->{ 'indent_type_' . $type } = 0; |
50
|
20
|
|
|
|
|
25
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub indent_on { |
55
|
260
|
|
|
260
|
1
|
388
|
my ( $self, $type ) = @_; |
56
|
260
|
100
|
|
|
|
534
|
if ( $type eq 'Mail::AuthenticationResults::Header::Entry' ) { |
57
|
77
|
100
|
|
|
|
295
|
return 1 if ! defined $self->{ 'indent_type_' . $type }; #5.8 |
58
|
43
|
|
|
|
|
126
|
return $self->{ 'indent_type_' . $type }; |
59
|
|
|
|
|
|
|
} |
60
|
183
|
100
|
|
|
|
411
|
if ( $type eq 'Mail::AuthenticationResults::Header::SubEntry' ) { |
|
|
100
|
|
|
|
|
|
61
|
110
|
100
|
|
|
|
355
|
return 0 if ! defined $self->{ 'indent_type_' . $type }; #5.8 |
62
|
67
|
|
|
|
|
185
|
return $self->{ 'indent_type_' . $type }; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif ( $type eq 'Mail::AuthenticationResults::Header::Comment' ) { |
65
|
72
|
100
|
|
|
|
258
|
return 0 if ! defined $self->{ 'indent_type_' . $type }; #5.8 |
66
|
28
|
|
|
|
|
80
|
return $self->{ 'indent_type_' . $type }; |
67
|
|
|
|
|
|
|
} |
68
|
1
|
|
|
|
|
3
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub set_eol { |
73
|
3
|
|
|
3
|
1
|
54
|
my ( $self, $eol ) = @_; |
74
|
3
|
100
|
|
|
|
18
|
if ( $eol =~ /^\r?\n$/ ) { |
75
|
2
|
|
|
|
|
4
|
$self->{ 'eol' } = $eol; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
1
|
|
|
|
|
17
|
croak 'Invalid eol string'; |
79
|
|
|
|
|
|
|
} |
80
|
2
|
|
|
|
|
4
|
return $self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub eol { |
85
|
290
|
|
|
290
|
1
|
484
|
my ( $self ) = @_; |
86
|
290
|
100
|
|
|
|
775
|
return "\n" if ! defined $self->{ 'eol' }; #5.8 |
87
|
14
|
|
|
|
|
25
|
return $self->{ 'eol' }; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub fold_at { |
92
|
35
|
|
|
35
|
1
|
90
|
my ( $self ) = @_; |
93
|
35
|
|
|
|
|
189
|
return $self->{ 'fold_at' }; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub set_fold_at { |
98
|
4
|
|
|
4
|
1
|
74
|
my ( $self, $fold_at ) = @_; |
99
|
4
|
|
|
|
|
7
|
$self->{ 'fold_at' } = $fold_at; |
100
|
4
|
|
|
|
|
10
|
return $self; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub force_fold_at { |
105
|
32
|
|
|
32
|
1
|
63
|
my ( $self ) = @_; |
106
|
32
|
|
|
|
|
126
|
return $self->{ 'force_fold_at' }; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub set_force_fold_at { |
111
|
1
|
|
|
1
|
1
|
33
|
my ( $self, $fold_at ) = @_; |
112
|
1
|
|
|
|
|
3
|
$self->{ 'force_fold_at' } = $fold_at; |
113
|
1
|
|
|
|
|
4
|
return $self; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub set_indent_style { |
118
|
11
|
|
|
11
|
1
|
106
|
my ( $self, $style ) = @_; |
119
|
|
|
|
|
|
|
|
120
|
11
|
100
|
|
|
|
53
|
if ( $style eq 'none' ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
121
|
3
|
|
|
|
|
12
|
$self->clear_indent_on( 'Mail::AuthenticationResults::Header::Entry' ); |
122
|
3
|
|
|
|
|
13
|
$self->clear_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' ); |
123
|
3
|
|
|
|
|
8
|
$self->clear_indent_on( 'Mail::AuthenticationResults::Header::Comment' ); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
elsif ( $style eq 'entry' ) { |
126
|
5
|
|
|
|
|
32
|
$self->set_indent_by( 4 ); |
127
|
5
|
|
|
|
|
20
|
$self->set_indent_on( 'Mail::AuthenticationResults::Header::Entry' ); |
128
|
5
|
|
|
|
|
15
|
$self->clear_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' ); |
129
|
5
|
|
|
|
|
11
|
$self->clear_indent_on( 'Mail::AuthenticationResults::Header::Comment' ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif ( $style eq 'subentry' ) { |
132
|
1
|
|
|
|
|
5
|
$self->set_indent_by( 4 ); |
133
|
1
|
|
|
|
|
3
|
$self->set_indent_on( 'Mail::AuthenticationResults::Header::Entry' ); |
134
|
1
|
|
|
|
|
5
|
$self->set_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' ); |
135
|
1
|
|
|
|
|
5
|
$self->clear_indent_on( 'Mail::AuthenticationResults::Header::Comment' ); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
elsif ( $style eq 'full' ) { |
138
|
1
|
|
|
|
|
4
|
$self->set_indent_by( 4 ); |
139
|
1
|
|
|
|
|
6
|
$self->set_indent_on( 'Mail::AuthenticationResults::Header::Entry' ); |
140
|
1
|
|
|
|
|
4
|
$self->set_indent_on( 'Mail::AuthenticationResults::Header::SubEntry' ); |
141
|
1
|
|
|
|
|
4
|
$self->set_indent_on( 'Mail::AuthenticationResults::Header::Comment' ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
else { |
144
|
1
|
|
|
|
|
22
|
croak "Unknown indent style $style"; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
10
|
|
|
|
|
27
|
return $self; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub safe_set_value { |
151
|
5
|
|
|
5
|
1
|
950
|
my ( $self, $value ) = @_; |
152
|
5
|
|
|
|
|
14
|
$self->set_value( $value ); |
153
|
3
|
|
|
|
|
11
|
return $self; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub set_value { |
157
|
60
|
|
|
60
|
1
|
1055
|
my ( $self, $value ) = @_; |
158
|
60
|
50
|
|
|
|
174
|
croak 'Does not have value' if ! $self->_HAS_VALUE(); # uncoverable branch true |
159
|
|
|
|
|
|
|
# HAS_VALUE is 1 for this class |
160
|
60
|
100
|
|
|
|
203
|
croak 'Value cannot be undefined' if ! defined $value; |
161
|
58
|
100
|
|
|
|
212
|
croak 'value should be an AuthServID type' if ref $value ne 'Mail::AuthenticationResults::Header::AuthServID'; |
162
|
56
|
|
|
|
|
228
|
$self->{ 'value' } = $value; |
163
|
56
|
|
|
|
|
167
|
return $self; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub add_parent { |
167
|
20
|
|
|
20
|
1
|
36
|
my ( $self, $parent ) = @_; |
168
|
20
|
|
|
|
|
32
|
return; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub add_child { |
172
|
126
|
|
|
126
|
1
|
6696
|
my ( $self, $child ) = @_; |
173
|
126
|
100
|
|
|
|
343
|
croak 'Cannot add a SubEntry as a child of a Header' if ref $child eq 'Mail::AuthenticationResults::Header::SubEntry'; |
174
|
125
|
|
|
|
|
356
|
return $self->SUPER::add_child( $child ); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub _as_hashref { |
178
|
2
|
|
|
2
|
|
4
|
my ( $self ) = @_; |
179
|
|
|
|
|
|
|
|
180
|
2
|
|
|
|
|
10
|
my $type = lc ref $self; |
181
|
2
|
|
|
|
|
16
|
$type =~ s/^(.*::)//; |
182
|
2
|
|
|
|
|
7
|
my $hashref = { 'type' => $type }; |
183
|
|
|
|
|
|
|
|
184
|
2
|
50
|
|
|
|
13
|
$hashref->{'key'} = $self->key() if $self->_HAS_KEY(); |
185
|
2
|
50
|
|
|
|
11
|
$hashref->{'authserv_id'} = $self->value()->_as_hashref() if $self->value(); |
186
|
2
|
50
|
|
|
|
6
|
if ( $self->_HAS_CHILDREN() ) { |
187
|
2
|
|
|
|
|
4
|
my @children = map { $_->_as_hashref() } @{ $self->children() }; |
|
16
|
|
|
|
|
34
|
|
|
2
|
|
|
|
|
8
|
|
188
|
2
|
|
|
|
|
6
|
$hashref->{'children'} = \@children; |
189
|
|
|
|
|
|
|
} |
190
|
2
|
|
|
|
|
167
|
return $hashref; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub as_string { |
194
|
30
|
|
|
30
|
1
|
2823
|
my ( $self ) = @_; |
195
|
30
|
|
|
|
|
157
|
my $header = Mail::AuthenticationResults::FoldableHeader->new(); |
196
|
30
|
100
|
|
|
|
108
|
$header->set_try_fold_at( $self->fold_at() ) if defined $self->fold_at(); |
197
|
30
|
50
|
|
|
|
114
|
$header->set_force_fold_at( $self->force_fold_at() ) if defined $self->force_fold_at(); |
198
|
30
|
|
|
|
|
102
|
$header->set_eol( $self->eol() ); |
199
|
30
|
|
|
|
|
91
|
$header->set_indent( ' ' x $self->indent_by() ); |
200
|
30
|
|
|
|
|
106
|
$header->set_sub_indent( ' ' ); |
201
|
30
|
|
|
|
|
106
|
$self->build_string( $header ); |
202
|
30
|
|
|
|
|
141
|
return $header->as_string(); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub build_string { |
206
|
32
|
|
|
32
|
1
|
86
|
my ( $self, $header ) = @_; |
207
|
32
|
|
|
|
|
66
|
my $value = q{}; |
208
|
32
|
100
|
|
|
|
120
|
if ( $self->value() ) { |
209
|
31
|
|
|
|
|
92
|
$self->value()->build_string( $header ); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
else { |
212
|
1
|
|
|
|
|
4
|
$header->string( 'unknown' ); |
213
|
|
|
|
|
|
|
} |
214
|
32
|
|
|
|
|
117
|
$header->separator( ';' ); |
215
|
|
|
|
|
|
|
|
216
|
32
|
|
|
|
|
52
|
my $sep = 0; |
217
|
32
|
|
|
|
|
66
|
foreach my $child ( @{ $self->children() } ) { |
|
32
|
|
|
|
|
112
|
|
218
|
79
|
100
|
|
|
|
221
|
$header->separator( ';' ) if $sep; |
219
|
79
|
|
|
|
|
125
|
$sep = 1; |
220
|
79
|
|
|
|
|
280
|
$child->as_string_prefix( $header ); |
221
|
79
|
|
|
|
|
209
|
$child->build_string( $header ); |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
32
|
100
|
|
|
|
65
|
if ( scalar @{ $self->search({ 'isa' => 'entry' } )->children() } == 0 ) { |
|
32
|
|
|
|
|
216
|
|
225
|
|
|
|
|
|
|
#if ( scalar @{ $self->children() } > 0 ) { |
226
|
|
|
|
|
|
|
# $value .= ' '; |
227
|
|
|
|
|
|
|
#} |
228
|
13
|
|
|
|
|
88
|
$header->space( ' ' ); |
229
|
13
|
|
|
|
|
31
|
$header->string ( 'none' ); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
32
|
|
|
|
|
136
|
return; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
__END__ |