line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::AuthenticationResults::Header::Comment; |
2
|
|
|
|
|
|
|
# ABSTRACT: Class modelling Comment parts of the Authentication Results Header |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require 5.008; |
5
|
29
|
|
|
29
|
|
80022
|
use strict; |
|
29
|
|
|
|
|
107
|
|
|
29
|
|
|
|
|
880
|
|
6
|
29
|
|
|
29
|
|
171
|
use warnings; |
|
29
|
|
|
|
|
75
|
|
|
29
|
|
|
|
|
1273
|
|
7
|
|
|
|
|
|
|
our $VERSION = '2.20230112'; # VERSION |
8
|
29
|
|
|
29
|
|
171
|
use Scalar::Util qw{ weaken }; |
|
29
|
|
|
|
|
52
|
|
|
29
|
|
|
|
|
1658
|
|
9
|
29
|
|
|
29
|
|
242
|
use Carp; |
|
29
|
|
|
|
|
91
|
|
|
29
|
|
|
|
|
2216
|
|
10
|
|
|
|
|
|
|
|
11
|
29
|
|
|
29
|
|
242
|
use base 'Mail::AuthenticationResults::Header::Base'; |
|
29
|
|
|
|
|
118
|
|
|
29
|
|
|
|
|
17835
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
352
|
|
|
352
|
|
1531
|
sub _HAS_VALUE{ return 1; } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub safe_set_value { |
17
|
13
|
|
|
13
|
1
|
923
|
my ( $self, $value ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
13
|
50
|
|
|
|
34
|
$value = q{} if ! defined $value; |
20
|
|
|
|
|
|
|
|
21
|
13
|
|
|
|
|
26
|
$value =~ s/\t/ /g; |
22
|
13
|
|
|
|
|
18
|
$value =~ s/\n/ /g; |
23
|
13
|
|
|
|
|
21
|
$value =~ s/\r/ /g; |
24
|
|
|
|
|
|
|
|
25
|
13
|
|
|
|
|
17
|
my $remain = $value; |
26
|
13
|
|
|
|
|
16
|
my $depth = 0; |
27
|
13
|
|
|
|
|
16
|
my $nested_ok = 1; |
28
|
13
|
|
|
|
|
40
|
while ( length $remain > 0 ) { |
29
|
119
|
|
|
|
|
153
|
my $first = substr( $remain,0,1 ); |
30
|
119
|
|
|
|
|
151
|
$remain = substr( $remain,1 ); |
31
|
119
|
100
|
|
|
|
184
|
$depth++ if $first eq '('; |
32
|
119
|
100
|
|
|
|
173
|
$depth-- if $first eq ')'; |
33
|
119
|
100
|
|
|
|
222
|
$nested_ok = 0 if $depth == -1; |
34
|
|
|
|
|
|
|
} |
35
|
13
|
100
|
|
|
|
28
|
$nested_ok = 0 if $depth != 0; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Remove parens if nested comments would be broken by them. |
38
|
13
|
100
|
|
|
|
24
|
if ( ! $nested_ok ) { |
39
|
5
|
|
|
|
|
15
|
$value =~ s/\(/ /g; |
40
|
5
|
|
|
|
|
14
|
$value =~ s/\)/ /g; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
13
|
|
|
|
|
42
|
$value =~ s/^\s+//; |
44
|
13
|
|
|
|
|
30
|
$value =~ s/\s+$//; |
45
|
|
|
|
|
|
|
#$value =~ s/;/ /g; |
46
|
|
|
|
|
|
|
|
47
|
13
|
|
|
|
|
36
|
$self->set_value( $value ); |
48
|
13
|
|
|
|
|
37
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub set_value { |
52
|
93
|
|
|
93
|
1
|
1063
|
my ( $self, $value ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
93
|
|
|
|
|
166
|
my $remain = $value; |
55
|
93
|
|
|
|
|
153
|
my $depth = 0; |
56
|
93
|
|
|
|
|
280
|
while ( length $remain > 0 ) { |
57
|
1682
|
|
|
|
|
2039
|
my $first = substr( $remain,0,1 ); |
58
|
1682
|
|
|
|
|
2108
|
$remain = substr( $remain,1 ); |
59
|
1682
|
100
|
|
|
|
2475
|
$depth++ if $first eq '('; |
60
|
1682
|
100
|
|
|
|
2449
|
$depth-- if $first eq ')'; |
61
|
1682
|
100
|
|
|
|
3244
|
croak 'Out of order parens in comment' if $depth == -1; |
62
|
|
|
|
|
|
|
} |
63
|
90
|
100
|
|
|
|
265
|
croak 'Mismatched parens in comment' if $depth != 0; |
64
|
88
|
50
|
|
|
|
279
|
croak 'Invalid characters in value' if $value =~ /\n/; |
65
|
88
|
50
|
|
|
|
207
|
croak 'Invalid characters in value' if $value =~ /\r/; |
66
|
|
|
|
|
|
|
|
67
|
88
|
|
|
|
|
283
|
$self->{ 'value' } = $value; |
68
|
88
|
|
|
|
|
338
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub build_string { |
72
|
83
|
|
|
83
|
1
|
179
|
my ( $self, $header ) = @_; |
73
|
83
|
|
|
|
|
204
|
$header->comment( '(' . $self->value() . ')' ); |
74
|
83
|
|
|
|
|
199
|
return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |