lib/Mail/DKIM2/Fold.pm

filter: Statementstmt 54.9% 105 / 191 Branchbran 45.7% 64 / 140 Conditioncond 45.9% 57 / 124 MC/DCmcdc 43.2% 32 / 74 Subroutinesub 75.0% 9 / 12 Podpod 100% 2 / 2 totaltotal 49.5% 269 / 543 CC 121 SCAR 50.1
CC
121
Cov
50%
fold_header
236.0
fold_header
236.0
_dkim2_fold_ok
66.5
CRAP 150.0
↑ Summary lib/Mail/DKIM2/Address.pm »
1 package Mail::DKIM2::Fold;
2 222 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 222 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 222 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 222 our $VERSION = '0.34';
7  
8 222 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 222 ▶use Mail::DKIM2::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 222 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 222 our @EXPORT_OK = qw(
13 fold_header
14 );
15  
16 # fold_header($line, [$margin], %opts): fold a header field we are creating
17 # -- never one read from elsewhere -- to $margin characters (default 72).
18 # $line is the whole field, "DKIM2-Signature: i=1; ..."; the result has
19 # "\r\n\t" between its lines. A tab shows as 8 columns, so continuation
20 # lines take $margin - 8 characters. It folds after a tag's ";" where it
21 # can, and otherwise only where the field's grammar allows FWS
22 # (_dkim2_fold_ok); a token that cannot fold stays whole on a long line.
23 1993 ▶sub fold_header {
Subroutine fold_header: called CC=36 SCAR=54.6
Pod documented
24 0 ▶ my ($line, $margin, %opts) = @_;
Subroutine fold_header: not called CC=36 SCAR=54.6
Pod documented
25 0 Mail::DKIM2::Util::check_options('fold_header', \%opts, qw(delimiters_only));
26 0 ▶ $margin //= 72;
Condition25%1/4
$margin //= 72
l!l
01992
$margin //= 72
l!l
00
MC/DC0%0/1
$margin //= 72
$margin
MC/DC0%0/1
$margin //= 72
$margin
Truth table50%1/2
A
A= $margin
Aresult
11
00
Truth table0%0/2
A
A= $margin
Aresult
11
00
27 # delimiters_only: break only after a ";" or a "," -- never at a space,
28 # never mid-token. For X-DKIM2-Info (draft-gondwana-dkim2-debug-header-01
29 # Section 5): a consumer ignores whitespace next to ";" and ",", and an
30 # emitter MUST NOT fold inside a token, so a hex digest or a quoted detail
31 # that will not fit stays whole on an over-long line (RFC 5322's 78 is a
32 # SHOULD; its 998 is the MUST, and nothing here approaches it).
33 0 my $delimiters_only = $opts{delimiters_only};
34 0 my $cont_margin = $margin - 8; # content chars on continuation lines
35  
36 0 ▶ return $line if length($line) <= $margin;
Branch: 2 branches
BranchTrueFalseTotal
if length $line <= $margin 1 1991 1992
if length $line <= $margin 0 0 0
37  
38 0 my @folded;
39 0 my $remaining = $line;
40 0 my $limit = $margin;
41 0 my %fold_state; # where the emitted text ends: see _dkim2_fold_feed
42  
43 0 ▶ while (length($remaining) > $limit) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $remaining > $limit) 11656 1954 13610
if (length $remaining > $limit) 0 0 0
44 # Find the best break point: prefer "; " boundaries, then
45 # any space. Look backwards from the limit.
46 0 my $break = -1;
47  
48 # Try to break at "; " (tag boundary)
49 0 my $search = substr($remaining, 0, $limit);
50 0 my $pos = rindex($search, '; ');
51 0 ▶ if ($pos > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($pos > 0) 4563 7093 11656
if ($pos > 0) 0 0 0
52 # Break after the semicolon, before the space
53 0 $break = $pos + 1;
54 }
55  
56 # If no tag boundary, try breaking at any space
57 0 ▶ if ($break < 0 && !$delimiters_only) {
Branch: 2 branches
BranchTrueFalseTotal
if ($break < 0 and not $delimiters_only) 7052 4604 11656
if ($break < 0 and not $delimiters_only) 0 0 0
Condition50%3/6
$break < 0 and not $delimiters_only
!ll&&!rl&&r
4563417052
$break < 0 and not $delimiters_only
!ll&&!rl&&r
000
MC/DC100%2/2
$break < 0 and not $delimiters_only
$break < 0 not $delimiters_only
MC/DC0%0/2
$break < 0 and not $delimiters_only
$break < 0 not $delimiters_only
Truth table100%3/3
A and not(B)
A= $break < 0B= not $delimiters_only
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $break < 0B= not $delimiters_only
ABresult
0X0
100
111
58 0 $pos = rindex($search, ' ');
59 0 ▶ $break = $pos if $pos > 0;
Branch: 2 branches
BranchTrueFalseTotal
if $pos > 0 3 7049 7052
if $pos > 0 0 0 0
60 }
61  
62 # If a space occurs within 2 chars before the limit, fold at
63 # the space rather than leaving a 1-2 char orphan before the
64 # next forced break.
65 0 ▶ if (!$delimiters_only && ($break < 0 || $limit - $break <= 2)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $delimiters_only and $break < 0 || $limit - $break <= 2) 7091 4565 11656
if (not $delimiters_only and $break < 0 || $limit - $break <= 2) 0 0 0
Condition50%6/12
not $delimiters_only and $break < 0 || $limit - $break <= 2
!ll&&!rl&&r
62539407091
$break < 0 or $limit - $break <= 2
l!l&&r!l&&!r
7049423940
not $delimiters_only and $break < 0 || $limit - $break <= 2
!ll&&!rl&&r
000
$break < 0 or $limit - $break <= 2
l!l&&r!l&&!r
000
MC/DC100%3/3
not $delimiters_only and $break < 0 || $limit - $break <= 2
not $delimiters_only $break < 0 $limit - $break <= 2
MC/DC0%0/3
not $delimiters_only and $break < 0 || $limit - $break <= 2
not $delimiters_only $break < 0 $limit - $break <= 2
Truth table100%4/4
not(A) and B or C
A= not $delimiters_onlyB= $break < 0C= $limit - $break <= 2
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/4
not(A) and B or C
A= not $delimiters_onlyB= $break < 0C= $limit - $break <= 2
ABCresult
0XX0
1000
11X1
1011
66 # Check for a space near the limit
67 0 for my $i (reverse ($limit - 3)..($limit - 1)) {
68 0 ▶ next if $i < 0 || $i >= length($remaining);
Branch: 2 branches
BranchTrueFalseTotal
if $i < 0 or $i >= length $remaining 0 338634 338634
if $i < 0 or $i >= length $remaining 0 0 0
Condition16%1/6
$i < 0 or $i >= length $remaining
l!l&&r!l&&!r
00338634
$i < 0 or $i >= length $remaining
l!l&&r!l&&!r
000
MC/DC0%0/2
$i < 0 or $i >= length $remaining
$i < 0 $i >= length $remaining
MC/DC0%0/2
$i < 0 or $i >= length $remaining
$i < 0 $i >= length $remaining
Truth table33%1/3
A or B
A= $i < 0B= $i >= length $remaining
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $i < 0B= $i >= length $remaining
ABresult
1X1
011
000
69 0 ▶ if (substr($remaining, $i, 1) eq ' ') {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($remaining, $i, 1) eq " ") 6 338628 338634
if (substr($remaining, $i, 1) eq " ") 0 0 0
70 0 $break = $i;
71 0 last;
72 }
73 }
74 }
75  
76 # A list-valued tag (the hn= header-name list in X-DKIM2-Info) has
77 # no spaces at all, so break after a comma rather than in the middle
78 # of a name: "lis" + "t-help" is not a header field that exists.
79 0 ▶ if ($break < 0 && $delimiters_only) {
Branch: 2 branches
BranchTrueFalseTotal
if ($break < 0 and $delimiters_only) 41 11615 11656
if ($break < 0 and $delimiters_only) 0 0 0
Condition50%3/6
$break < 0 and $delimiters_only
!ll&&!rl&&r
4566704941
$break < 0 and $delimiters_only
!ll&&!rl&&r
000
MC/DC100%2/2
$break < 0 and $delimiters_only
$break < 0 $delimiters_only
MC/DC0%0/2
$break < 0 and $delimiters_only
$break < 0 $delimiters_only
Truth table100%3/3
A and B
A= $break < 0B= $delimiters_only
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $break < 0B= $delimiters_only
ABresult
0X0
100
111
80 0 $pos = rindex($search, ',');
81 0 ▶ $break = $pos + 1 if $pos > 0;
Branch: 2 branches
BranchTrueFalseTotal
if $pos > 0 3 38 41
if $pos > 0 0 0 0
82 }
83  
84 # Delimiters only and none before the limit: take the first one
85 # after it, or give up and leave the rest whole.
86 0 ▶ if ($break < 0 && $delimiters_only) {
Branch: 2 branches
BranchTrueFalseTotal
if ($break < 0 and $delimiters_only) 38 11618 11656
if ($break < 0 and $delimiters_only) 0 0 0
Condition50%3/6
$break < 0 and $delimiters_only
!ll&&!rl&&r
4569704938
$break < 0 and $delimiters_only
!ll&&!rl&&r
000
MC/DC100%2/2
$break < 0 and $delimiters_only
$break < 0 $delimiters_only
MC/DC0%0/2
$break < 0 and $delimiters_only
$break < 0 $delimiters_only
Truth table100%3/3
A and B
A= $break < 0B= $delimiters_only
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $break < 0B= $delimiters_only
ABresult
0X0
100
111
87 0 my ($semi, $comma) = (index($remaining, ';', $limit), index($remaining, ',', $limit));
88 0 my @after = sort { $a <=> $b } grep { $_ >= 0 } $semi, $comma;
89 0 ▶ last unless @after && $after[0] < length($remaining) - 1;
Branch: 2 branches
BranchTrueFalseTotal
unless @after and $after[0] < length($remaining) - 1 37 1 38
unless @after and $after[0] < length($remaining) - 1 0 0 0
Condition33%2/6
@after and $after[0] < length($remaining) - 1
!ll&&!rl&&r
0371
@after and $after[0] < length($remaining) - 1
!ll&&!rl&&r
000
MC/DC50%1/2
@after and $after[0] < length($remaining) - 1
@after $after[0] < length($remaining) - 1
MC/DC0%0/2
@after and $after[0] < length($remaining) - 1
@after $after[0] < length($remaining) - 1
Truth table66%2/3
A and B
A= @afterB= $after[0] < length($remaining) - 1
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= @afterB= $after[0] < length($remaining) - 1
ABresult
0X0
100
111
90 0 $break = $after[0] + 1;
91 }
92  
93 # A DKIM2 field: the latest point before the limit where its grammar
94 # allows FWS (_dkim2_fold_ok), else the first one after it. A token
95 # with no such point -- a long d= Domain -- stays whole on an
96 # over-long line rather than being split into a different value
97 # (follow-up review F2). One pass, carrying the tag state forward a
98 # character at a time: an s= of thousands of items folds in linear
99 # time.
100 0 ▶ if ($break < 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($break < 0) 7049 4570 11619
if ($break < 0) 0 0 0
101 0 my %st = %fold_state;
102 0 for my $i (1 .. length($remaining) - 1) {
103 0 ▶ last if $i > $limit && $break >= 0;
Branch: 2 branches
BranchTrueFalseTotal
if $i > $limit and $break >= 0 7046 451200 458246
if $i > $limit and $break >= 0 0 0 0
Condition50%3/6
$i > $limit and $break >= 0
!ll&&!rl&&r
451136647046
$i > $limit and $break >= 0
!ll&&!rl&&r
000
MC/DC100%2/2
$i > $limit and $break >= 0
$i > $limit $break >= 0
MC/DC0%0/2
$i > $limit and $break >= 0
$i > $limit $break >= 0
Truth table100%3/3
A and B
A= $i > $limitB= $break >= 0
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $i > $limitB= $break >= 0
ABresult
0X0
100
111
104 0 my $prev = substr($remaining, $i - 1, 1);
105 0 _dkim2_fold_feed(\%st, $prev);
106 0 ▶ next unless $prev eq ';' || _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1));
Branch: 2 branches
BranchTrueFalseTotal
unless $prev eq ";" or _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1)) 133813 317387 451200
unless $prev eq ";" or _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1)) 0 0 0
Condition50%3/6
$prev eq ";" or _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
l!l&&r!l&&!r
2317385133813
$prev eq ";" or _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
l!l&&r!l&&!r
000
MC/DC100%2/2
$prev eq ";" or _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
$prev eq ";" _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
MC/DC0%0/2
$prev eq ";" or _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
$prev eq ";" _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
Truth table100%3/3
A or B
A= $prev eq ";"B= _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $prev eq ";"B= _dkim2_fold_ok(\%st, $prev, substr($remaining, $i, 1))
ABresult
1X1
011
000
107 0 ▶ if ($i <= $limit) { $break = $i; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($i <= $limit) 317385 2 317387
if ($i <= $limit) 0 0 0
108 0 ▶ $break = $i if $break < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $break < 0 2 0 2
if $break < 0 0 0 0
109 0 last;
110 }
111 0 ▶ last if $break < 0;
Branch: 2 branches
BranchTrueFalseTotal
if $break < 0 0 7049 7049
if $break < 0 0 0 0
112 }
113  
114 0 my $chunk = substr($remaining, 0, $break);
115 0 $remaining = substr($remaining, $break);
116  
117 # Strip trailing WSP from chunk, leading WSP from remainder
118 0 $chunk =~ s/\s+$//;
119 0 $remaining =~ s/^\s+//;
120  
121 0 _dkim2_fold_feed(\%fold_state, $_) for split //, $chunk;
122 0 push @folded, $chunk;
123 0 $limit = $cont_margin;
124 }
125 0 ▶ push @folded, $remaining if length($remaining);
Branch: 2 branches
BranchTrueFalseTotal
if length $remaining 1991 0 1991
if length $remaining 0 0 0
126  
127 # RFC 5322 §2.1.1: 998 is a MUST. Nothing a DKIM2 signer emits has a
128 # token that long, so this is a caller error, not a field to send.
129 0 ▶ if (!$delimiters_only) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($delimiters_only) 1780 211 1991
unless ($delimiters_only) 0 0 0
130 0 for (@folded) {
131 0 ▶ Carp::croak("fold_header: a line exceeds 998 characters with no place to fold")
Branch: 2 branches
BranchTrueFalseTotal
if length $_ > 998 0 12811 12811
if length $_ > 998 0 0 0
132 if length > 998;
133 }
134 }
135  
136 0 return join("\r\n\t", @folded);
137 }
138  
139 # fold_header's view of a DKIM2 field read so far, one character at a time:
140 # the current tag's name (undef until its "=", with the text before it in
141 # pending) and how many ":" the current list item has had.
142 1096504 ▶sub _dkim2_fold_feed {
Subroutine _dkim2_fold_feed: called CC=8 SCAR=28.2
143 0 ▶ my ($st, $c) = @_;
Subroutine _dkim2_fold_feed: not called CC=8 SCAR=28.2
144 0 ▶ if ($c eq ';') { %$st = (); return }
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq ";") 9891 1086613 1096504
if ($c eq ";") 0 0 0
145 0 ▶ if (!defined $st->{name}) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $st->{"name"}) 67686 1018927 1086613
unless (defined $st->{"name"}) 0 0 0
146 0 $st->{pending} .= $c;
147 0 ▶ return unless $c eq '=';
Branch: 2 branches
BranchTrueFalseTotal
unless $c eq "=" 55775 11911 67686
unless $c eq "=" 0 0 0
148 0 ($st->{name}) = $st->{pending} =~ /\A\s*(?:[A-Za-z0-9-]+:\s*)?([A-Za-z][A-Za-z0-9_]*)\s*=\z/;
149 0 ▶ $st->{name} = defined $st->{name} ? lc $st->{name} : '';
Branch: 2 branches
BranchTrueFalseTotal
defined $st->{'name'} ? : 11911 0 11911
defined $st->{'name'} ? : 0 0 0
150 0 $st->{colons} = 0;
151 0 return;
152 }
153 0 ▶ if ($c eq ',' || $c eq '|') { $st->{colons} = 0 }
Branch: 4 branches
BranchTrueFalseTotal
if ($c eq ',' or $c eq '|') { } 17346 1001581 1018927
elsif ($c eq ':') { } 35985 965596 1001581
if ($c eq ',' or $c eq '|') { } 0 0 0
elsif ($c eq ':') { } 0 0 0
Condition50%3/6
$c eq "," or $c eq "|"
l!l&&r!l&&!r
1215161311001581
$c eq "," or $c eq "|"
l!l&&r!l&&!r
000
MC/DC100%2/2
$c eq "," or $c eq "|"
$c eq "," $c eq "|"
MC/DC0%0/2
$c eq "," or $c eq "|"
$c eq "," $c eq "|"
Truth table100%3/3
A or B
A= $c eq ","B= $c eq "|"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $c eq ","B= $c eq "|"
ABresult
1X1
011
000
154 0 elsif ($c eq ':') { $st->{colons}++ }
155 }
156  
157 # May the field fold between $prev and $next, in state $st (_dkim2_fold_feed,
158 # fed up to and including $prev)? The grammars (-09 §9, §10) allow FWS
159 # inside a base64string (§2.13) and in a few list positions, and nowhere in
160 # a Domain, selector, algorithm or hash name, so only these are offered:
161 # - between two base64 characters of mf=, rt=, r=, of an h= digest (after
162 # the hash name's ":"), or of an s= signature value (after both ":"s);
163 # - on either side of a ":" in s= and h=, and of a "," or "|" joining
164 # their members (-09 §9.3, §10.9);
165 # - after a "," in any other list but rt=: f= allows FWS around commas,
166 # and an unknown tag's x-tag-value allows FWS between characters
167 # (X-DKIM2-Info's hn= list folds here too). rt= is
168 # base64string *("," base64string) (§10.6), and a base64string cannot
169 # start with FWS, so its commas take none -- though the generic
170 # tag-value grammar (§8) would allow it; rt= folds inside the base64.
171 451200 ▶sub _dkim2_fold_ok {
Subroutine _dkim2_fold_ok: called CC=19 SCAR=42.0
172 0 ▶ my ($st, $prev, $next) = @_;
Subroutine _dkim2_fold_ok: not called CC=19 SCAR=42.0
173 0 my $name = $st->{name};
174 0 ▶ return 0 unless defined $name && length $name;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $name and length $name 1133 450067 451200
unless defined $name and length $name 0 0 0
Condition33%2/6
defined $name and length $name
!ll&&!rl&&r
11330450067
defined $name and length $name
!ll&&!rl&&r
000
MC/DC50%1/2
defined $name and length $name
defined $name length $name
MC/DC0%0/2
defined $name and length $name
defined $name length $name
Truth table66%2/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
175 # sig-set and hash-set allow FWS on either side of their ":"s, and the
176 # lists of them on either side of each "," and "|" (§10.9, §9.3) -- but
177 # not after a header hash, before the ":" ending it: its padding is
178 # the end of the base64string, and the grammar has no FWS there.
179 0 ▶ return 0 if $prev eq '=' && $next eq ':';
Branch: 2 branches
BranchTrueFalseTotal
if $prev eq "=" and $next eq ":" 173 449894 450067
if $prev eq "=" and $next eq ":" 0 0 0
Condition50%3/6
$prev eq "=" and $next eq ":"
!ll&&!rl&&r
4479421952173
$prev eq "=" and $next eq ":"
!ll&&!rl&&r
000
MC/DC100%2/2
$prev eq "=" and $next eq ":"
$prev eq "=" $next eq ":"
MC/DC0%0/2
$prev eq "=" and $next eq ":"
$prev eq "=" $next eq ":"
Truth table100%3/3
A and B
A= $prev eq "="B= $next eq ":"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $prev eq "="B= $next eq ":"
ABresult
0X0
100
111
180 return 1 if ($name eq 's' || $name eq 'h')
181 0 ▶ && grep { $_ eq ':' || $_ eq ',' || $_ eq '|' } $prev, $next;
Branch: 2 branches
BranchTrueFalseTotal
if $name eq "s" || $name eq "h" and grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next 47954 401940 449894
if $name eq "s" || $name eq "h" and grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next 0 0 0
Condition50%12/24
$name eq "s" || $name eq "h" and grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
!ll&&!rl&&r
2832637361447954
$name eq "s" or $name eq "h"
l!l&&r!l&&!r
4099361163228326
$_ eq ':' || $_ eq ',' || $_ eq '|'
l!l&&r!l&&!r
3584916131791156
$_ eq ":" or $_ eq ","
l!l&&r!l&&!r
3581336807287
$name eq "s" || $name eq "h" and grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
!ll&&!rl&&r
000
$name eq "s" or $name eq "h"
l!l&&r!l&&!r
000
$_ eq ':' || $_ eq ',' || $_ eq '|'
l!l&&r!l&&!r
000
$_ eq ":" or $_ eq ","
l!l&&r!l&&!r
000
MC/DC100%3/3
$name eq "s" || $name eq "h" and grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
$name eq "s" $name eq "h" grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
MC/DC100%3/3
$_ eq ':' || $_ eq ',' || $_ eq '|'
$_ eq ":" $_ eq "," $_ eq '|'
MC/DC0%0/3
$name eq "s" || $name eq "h" and grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
$name eq "s" $name eq "h" grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
MC/DC0%0/3
$_ eq ':' || $_ eq ',' || $_ eq '|'
$_ eq ":" $_ eq "," $_ eq '|'
Truth table100%5/5
A or B and C
A= $name eq "s"B= $name eq "h"C= grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
ABCresult
00X0
1X00
0100
1X11
0111
Truth table100%4/4
A or B || C
A= $_ eq ":"B= $_ eq ","C= $_ eq '|'
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/5
A or B and C
A= $name eq "s"B= $name eq "h"C= grep {$_ eq ":" or $_ eq "," or $_ eq "|";} $prev, $next
ABCresult
00X0
1X00
0100
1X11
0111
Truth table0%0/4
A or B || C
A= $_ eq ":"B= $_ eq ","C= $_ eq '|'
ABCresult
1XX1
01X1
0011
0000
182 0 ▶ return 1 if $prev eq ',' && $name ne 'rt';
Branch: 2 branches
BranchTrueFalseTotal
if $prev eq "," and $name ne "rt" 17 401923 401940
if $prev eq "," and $name ne "rt" 0 0 0
Condition50%3/6
$prev eq "," and $name ne "rt"
!ll&&!rl&&r
40145247117
$prev eq "," and $name ne "rt"
!ll&&!rl&&r
000
MC/DC100%2/2
$prev eq "," and $name ne "rt"
$prev eq "," $name ne "rt"
MC/DC0%0/2
$prev eq "," and $name ne "rt"
$prev eq "," $name ne "rt"
Truth table100%3/3
A and B
A= $prev eq ","B= $name ne "rt"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $prev eq ","B= $name ne "rt"
ABresult
0X0
100
111
183 0 ▶ return 0 unless $prev =~ m{[A-Za-z0-9+/=]} && $next =~ m{[A-Za-z0-9+/=]};
Branch: 2 branches
BranchTrueFalseTotal
unless $prev =~ m[[A-Za-z0-9+/=]]u and $next =~ m[[A-Za-z0-9+/=]]u 2646 399277 401923
unless $prev =~ m[[A-Za-z0-9+/=]]u and $next =~ m[[A-Za-z0-9+/=]]u 0 0 0
Condition50%3/6
$prev =~ m[[A-Za-z0-9+/=]]u and $next =~ m[[A-Za-z0-9+/=]]u
!ll&&!rl&&r
13091337399277
$prev =~ m[[A-Za-z0-9+/=]]u and $next =~ m[[A-Za-z0-9+/=]]u
!ll&&!rl&&r
000
MC/DC100%2/2
$prev =~ m[[A-Za-z0-9+/=]]u and $next =~ m[[A-Za-z0-9+/=]]u
$prev =~ m[[A-Za-z0-9+/=]]u $next =~ m[[A-Za-z0-9+/=]]u
MC/DC0%0/2
$prev =~ m[[A-Za-z0-9+/=]]u and $next =~ m[[A-Za-z0-9+/=]]u
$prev =~ m[[A-Za-z0-9+/=]]u $next =~ m[[A-Za-z0-9+/=]]u
Truth table100%3/3
A and B
A= $prev =~ m[[A-Za-z0-9+/=]]uB= $next =~ m[[A-Za-z0-9+/=]]u
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $prev =~ m[[A-Za-z0-9+/=]]uB= $next =~ m[[A-Za-z0-9+/=]]u
ABresult
0X0
100
111
184 0 ▶ return 1 if $name eq 'mf' || $name eq 'rt' || $name eq 'r';
Branch: 2 branches
BranchTrueFalseTotal
if $name eq "mf" or $name eq "rt" or $name eq "r" 26995 372282 399277
if $name eq "mf" or $name eq "rt" or $name eq "r" 0 0 0
Condition50%6/12
$name eq "mf" or $name eq "rt" or $name eq "r"
l!l&&r!l&&!r
210855910372282
$name eq "mf" or $name eq "rt"
l!l&&r!l&&!r
25220833378192
$name eq "mf" or $name eq "rt" or $name eq "r"
l!l&&r!l&&!r
000
$name eq "mf" or $name eq "rt"
l!l&&r!l&&!r
000
MC/DC100%3/3
$name eq "mf" or $name eq "rt" or $name eq "r"
$name eq "mf" $name eq "rt" $name eq "r"
MC/DC0%0/3
$name eq "mf" or $name eq "rt" or $name eq "r"
$name eq "mf" $name eq "rt" $name eq "r"
Truth table100%4/4
A or B or C
A= $name eq "mf"B= $name eq "rt"C= $name eq "r"
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A or B or C
A= $name eq "mf"B= $name eq "rt"C= $name eq "r"
ABCresult
1XX1
01X1
0011
0000
185 0 ▶ return $st->{colons} >= 1 if $name eq 'h';
Branch: 2 branches
BranchTrueFalseTotal
if $name eq "h" 11101 361181 372282
if $name eq "h" 0 0 0
186 0 ▶ return $st->{colons} >= 2 if $name eq 's';
Branch: 2 branches
BranchTrueFalseTotal
if $name eq "s" 360878 303 361181
if $name eq "s" 0 0 0
187 0 return 0;
188 }
189  
190 222 1;
191  
192 __END__
↑ Summary lib/Mail/DKIM2/Address.pm »