Branch Coverage

blib/lib/Mail/DKIM/Iterator.pm
Criterion Covered Total %
branch 178 260 68.4


line true false branch
68 24 22 if (my $sig = delete $args{'sign'})
71 24 0 if ref $sig ne "ARRAY"
75 24 0 if ref $_
77 0 24 unless $s
91 19 89 if (ref $arg) { }
99 46 43 if (defined $self->{'_hdrbuf'}) { }
102 0 46 unless $self->{'_hdrbuf'} =~ /(\r?\n)\1/g
108 22 24 if ($self->{'extract_sig'} and my(@sig) = _parse_header($self->{'header'}))
110 0 22 if (my $f = $self->{'filter'})
113 22 0 if @sig
116 44 2 if $arg ne ""
123 0 89 if (not $self->{'sig'}) { }
131 108 0 unless @_
134 0 108 unless $rv
141 46 62 if $_->status
145 43 19 unless $sig->{'bh:computed'}
149 38 24 if ($sig->{'b'})
151 38 0 unless $self->{'records'}{$name}
156 43 65 $need_more_data ? :
163 0 0 if $self->{'header'} and $self->{'sig'}
174 0 0 $ar ? :
175 0 0 unless (shift())->result
182 0 216 if defined $self->{'_hdrbuf'}
183 0 216 unless $self->{'sig'}
189 46 170 if ($sig->{':result'})
194 1 169 if ($sig->{'error'})
206 72 97 unless ($sig->{'b'})
208 48 24 if (not $sig->{'bh:computed'}) { }
215 24 0 $dkim_sig ? :
226 1 96 if ($sig->{'x'} and $sig->{'x'} < time)
233 18 78 if ($txt and !ref($txt) || ref $txt eq 'ARRAY') { }
1 154 elsif (exists $self->{'records'}{$dns} and not $txt) { }
237 0 18 ref $txt ? :
238 17 1 if (my $r = parse_dkimkey($_, \$error))
244 1 17 if $error
252 20 76 if @v
261 22 48 unless ref $v
263 48 22 if ($for_signing)
268 1 69 if (($v->{'v'} // '') ne '1') { }
0 69 elsif (not $v->{'d'}) { }
0 69 elsif (not $v->{'s'}) { }
0 69 elsif (not $v->{'h'}) { }
0 69 elsif ($v->{'l'} and not $v->{'l'} =~ /^\d{1,76}\z/) { }
0 69 elsif (do { $v->{'q'} = lc($v->{'q'} // 'dns/txt'); $v->{'q'} ne 'dns/txt' }) { }
284 1 69 if $$error
292 0 69 unless grep {$_ eq "from";} @h
295 48 21 if ($for_signing) { }
298 0 48 if exists $v->{'t'}
299 0 48 if (defined $v->{'x'} and not $v->{'x'} =~ /^\+?\d{1,12}\z/)
303 0 21 if (not $v->{'b'} && ($v->{'b:bin'} = _decode64($v->{'b'}))) { }
0 21 elsif (not $v->{'bh'} && ($v->{'bh:bin'} = _decode64($v->{'bh'}))) { }
0 21 elsif ($v->{'t'} and not $v->{'t'} =~ /^\d{1,12}\z/) { }
1 20 elsif ($v->{'x'}) { }
310 0 1 if (not $v->{'x'} =~ /^\d{1,12}\z/) { }
0 2 elsif ($v->{'t'} and $v->{'x'} < $v->{'t'}) { }
317 0 21 if ($v->{'i'}) { }
319 0 0 if (lc($v->{'i'}) =~ /\@([^\@]+)$/) { }
322 0 0 unless $v->{'i:domain'} =~ /^(.+\.)?\Q$v->{'d'}\E\z/
332 0 69 unless (my($hdrc, $bodyc) = $v->{'c'} =~ m[^(relaxed|simple)(?:/(relaxed|simple))?$])
336 0 69 unless (my($kalgo, $halgo) = $v->{'a'} =~ /^(rsa)-(sha(?:1|256))$/)
339 0 69 if $$error
354 18 0 unless ref $v
355 1 17 unless ($v and %$v)
360 0 17 if (($v->{'v'} ||= 'DKIM1') ne 'DKIM1') { }
0 17 elsif (($v->{'k'} //= 'rsa') ne 'rsa') { }
365 0 17 if (exists $v->{'g'})
378 0 0 unless ($v->{'s'}{'*'} or $v->{'s'}{'email'})
395 22 2 if (ref $sig and $sig->{'h_auto'})
406 22 132 if exists $oh{$k} and --$oh{$k} == 0
411 0 24 unless $sig = parse_signature($sig, $error, 1)
415 0 24 if not $sig{'t'} and exists $sig{'t'}
417 0 24 if $sig{'x'} and $sig{'x'} =~ /^\+(\d+)$/
418 0 24 unless ($sig{'a:key'} eq "rsa")
423 0 24 if $sig{':i'}
424 0 24 if $sig{':z'}
434 168 24 if /:/
443 124 94 @lines == 1 ? :
444 173 45 if (length $append <= $x80) { }
23 22 elsif (length $append <= 80) { }
450 44 4 if ($x80 > 10)
452 22 22 if $append eq ""
461 0 24 unless ($sig->{'a:key'} eq "rsa")
468 0 24 ref $key ? :
469 0 24 unless ($priv)
480 72 13 if $x80 > 10
481 61 24 if $data ne ""
495 1 95 if (defined $sig->{'bh:computed'} and $sig->{'bh:computed'} ne $sig->{'bh:bin'})
499 76 19 unless $param
501 0 19 unless %$param
502 1 18 if $param->{'tempfail'}
503 1 17 if $param->{'permfail'}
505 0 17 $param->{'t'}{'y'} ? :
506 0 17 unless $param->{'p'}
509 0 17 unless $param->{'h'}{$sig->{'a:hash'}}
512 0 0 if $param->{'t'}{'s'} and $sig->{'i:domain'} and $sig->{'i:domain'} ne $sig->{'d'}
515 0 17 if $param->{'g'} and not $sig->{'i'} =~ /$param->{'g'}/
518 0 17 unless defined $sig->{'bh:computed'}
520 3 14 unless (eval { do { die ["permerror", "using public key failed"] unless my $rsa = "Crypt::OpenSSL::RSA"->new_public_key(do { local $_ = $param->{'p'}; s/\s+//g; s/(.{1,64})/$1\n/g; "-----BEGIN PUBLIC KEY-----\n$_-----END PUBLIC KEY-----\n" }); $rsa->use_no_padding; die ["permerror", "header sig corrupt"] unless my $bencrypt = eval { do { $rsa->encrypt($sig->{'b:bin'}) } }; my $expect = _emsa_pkcs1_v15($sig->{'a:hash'}, $sig->{'h:hash'}, $rsa->size); if ($expect ne $bencrypt) { die [$FAIL, "header sig mismatch"]; } ; 1 } })
521 0 16 unless my $rsa = "Crypt::OpenSSL::RSA"->new_public_key(do { local $_ = $param->{'p'}; s/\s+//g; s/(.{1,64})/$1\n/g; "-----BEGIN PUBLIC KEY-----\n$_-----END PUBLIC KEY-----\n" })
528 1 15 unless my $bencrypt = eval { do { $rsa->encrypt($sig->{'b:bin'}) } }
532 1 14 if ($expect ne $bencrypt)
539 2 1 if ref $@
542 12 2 unless $sig->{':warning'}
556 21 1 if ($sig) { }
562 2 19 if (my(@h) = grep({$critical{$_} < 0;} keys %critical))
585 0 39 if $pad < 8
630 0 467 if ($k eq 'dkim-signature') { }
632 0 0 if $_ eq $dkh
724 0 87 if $sig->{'bh:computed'}
726 45 1 if (not $sig->{'error'} and my $digest = $digest{$sig->{'a:hash'}}() and my $transform = $bodyc{$sig->{'c:body'}}()) { }
734 1 43 defined $sig->{'l'} ? :
1 44 $sig->{'l'} ? :
742 1 86 if $bh->{'done'}
744 43 43 if ($buf eq "")
748 0 43 if $tbuf eq ""
750 41 2 unless defined $bh->{'l'}
751 1 1 if (ref $bh->{'l'})
755 1 0 if ($bh->{'l'} > 0) { }
756 0 1 if ($bh->{'l'} -= length $tbuf) > 0
768 44 42 if $tbuf ne ""
769 42 44 unless $bh->{'done'}
774 1 43 if $bh->{'_data_after_l'}
803 0 295 if (defined $3)
807 40 255 unless defined $1
808 0 255 if (exists $v{$1})
825 48 0 if $pad
862 0 8 if ($_[0][2] > 0) { }
863 16 0 $_[0][2] > 0 ? :
867 0 0 unless $self->[2]
869 0 0 if defined $self->[3] and $self->[3] ne ""