Sisimai/Lhost/KDDI.pm

filter: Statementstmt 94.8% 55 / 58 Branchbran 70.5% 24 / 34 Conditioncond 52.0% 13 / 25 MC/DCmcdc 35.7% 5 / 14 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 75.5% 105 / 139 CC 31 SCAR 36.5
CC
31
Cov
79%
inquire
44.3
BEGIN
1.0
BEGIN
1.0
CRAP 38.3
« Sisimai/Lhost/V5sendmail.pm ↑ Summary Sisimai/Lhost/ApacheJames.pm »
1 package Sisimai::Lhost::KDDI;
2 41 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 41 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'au by KDDI: https://www.au.kddi.com' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 914 ▶sub inquire {
Subroutine inquire: called CC=31 SCAR=37.9
Pod documented
9 # Detect an error from au by KDDI
10 # @param [Hash] mhead Message headers of a bounce email
11 # @param [String] mbody Message body of a bounce email
12 # @return [Hash] Bounce data list and message/rfc822 part
13 # @return [undef] failed to decode or the arguments are missing
14 # @since v4.0.0
15 914 my $class = shift;
16 914 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9131
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 913 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9121
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18 912 ▶ my $match = 0; $match ||= 1 if Sisimai::String->aligned(\$mhead->{'from'}, ['no-reply@.', '.dion.ne.jp']);
Branch: 1 branch
BranchTrueFalseTotal
if "Sisimai::String"->aligned(\$mhead->{"from"}, ["no-reply\@.", ".dion.ne.jp"]) 0 912 912
Condition0%0/2
$match ||= 1
l!l
00
MC/DC0%0/1
$match ||= 1
$match
Truth table0%0/2
A
A= $match
Aresult
11
00
19 912 ▶ $match ||= 1 if $mhead->{'reply-to'} && $mhead->{'reply-to'} eq 'no-reply@app.auone-net.jp';
Branch: 1 branch
BranchTrueFalseTotal
if $mhead->{"reply-to"} and $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp" 16 896 912
Condition80%4/5
$mhead->{"reply-to"} and $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
!ll&&!rl&&r
8791716
$match ||= 1
l!l
016
MC/DC100%2/2
$mhead->{"reply-to"} and $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
$mhead->{"reply-to"} $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
MC/DC0%0/1
$match ||= 1
$match
Truth table100%3/3
A and B
A= $mhead->{"reply-to"}B= $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
ABresult
0X0
100
111
Truth table50%1/2
A
A= $match
Aresult
11
00
20 912 ▶ $match ||= 1 if grep { rindex($_, 'ezweb.ne.jp (') > -1 } $mhead->{'received'}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if grep {rindex($_, "ezweb.ne.jp (") != -1;} @{$$mhead{"received"}} 0 912 912
Condition0%0/2
$match ||= 1
l!l
00
MC/DC0%0/1
$match ||= 1
$match
Truth table0%0/2
A
A= $match
Aresult
11
00
21 912 ▶ $match ||= 1 if grep { rindex($_, '.au.com (') > -1 } $mhead->{'received'}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if grep {rindex($_, ".au.com (") != -1;} @{$$mhead{"received"}} 0 912 912
Condition0%0/2
$match ||= 1
l!l
00
MC/DC0%0/1
$match ||= 1
$match
Truth table0%0/2
A
A= $match
Aresult
11
00
22 912 ▶ return undef unless $match;
Branch: 1 branch
BranchTrueFalseTotal
unless $match 896 16 912
23  
24 16 state $indicators = __PACKAGE__->INDICATORS;
25 16 state $boundaries = ['Content-Type: message/rfc822'];
26 16 state $startingof = {'message' => ['Your mail sent on:', 'Your mail attempted to be delivered on:']};
27  
28 16 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 16 16
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
160
MC/DC0%0/1
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
"Sisimai::RFC5322"->part($mbody, $boundaries)
Truth table50%1/2
A
A= "Sisimai::RFC5322"->part($mbody, $boundaries)
Aresult
11
00
29 16 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
30 16 my $readcursor = 0; # (Integer) Points the current cursor position
31 16 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
32  
33 16 for my $e ( split("\n", $emailparts->[0]) ) {
34 # Read error messages and delivery status lines from the head of the email to the previous
35 # line of the beginning of the original message.
36 138 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 106 32 138
37 # Beginning of the bounce message or message/delivery-status part
38 106 ▶ $readcursor |= $indicators->{'deliverystatus'} if grep { index($e, $_) == 0 } $startingof->{'message'}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if grep {index($e, $_) == 0;} @{$$startingof{"message"}} 16 90 106
39 }
40 138 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 90 48 138
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
90048
MC/DC50%1/2
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
($readcursor & $indicators->{"deliverystatus"}) == 0 $e eq ""
Truth table66%2/3
A or B
A= ($readcursor & $indicators->{"deliverystatus"}) == 0B= $e eq ""
ABresult
1X1
011
000
41  
42 48 $v = $dscontents->[-1];
43 48 ▶ if( index($e, ' Could not be delivered to: <') > -1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (index($e, ' Could not be delivered to: <') != -1) { } 16 32 48
elsif (index($e, 'Your mail sent on: ') != -1) { } 16 16 32
44 # Your mail sent on: Thu, 29 Apr 2010 11:04:47 +0900
45 # Could not be delivered to: <******@**.***.**>
46 # As their mailbox is full.
47 16 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 16 16
48 # There are multiple recipient addresses in the message body.
49 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
50 0 $v = $dscontents->[-1];
51 }
52  
53 16 my $r = Sisimai::Address->s3s4(substr($e, index($e, '<') + 1, ));
54 16 ▶ next unless Sisimai::Address->is_emailaddress($r);
Branch: 1 branch
BranchTrueFalseTotal
unless "Sisimai::Address"->is_emailaddress($r) 0 16 16
55 16 $v->{'recipient'} = $r;
56 16 $recipients++;
57  
58 } elsif( index($e, 'Your mail sent on: ') > -1 ) {
59 # Your mail sent on: Thu, 29 Apr 2010 11:04:47 +0900
60 16 $v->{'date'} = substr($e, 19, );
61  
62 } else {
63 # As their mailbox is full.
64 16 ▶ $v->{'diagnosis'} .= $e.' ' if index($e, ' ') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, " ") == 0 16 0 16
65 }
66 }
67 16 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 16 16
68  
69 16 require Sisimai::Eb;
70 16 require Sisimai::SMTP::Command;
71 16 for my $e ( @$dscontents ) {
72 16 ▶ $e->{'command'} = Sisimai::SMTP::Command->find($e->{'diagnosis'}) || '';
Condition50%1/2
'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
l!l
016
MC/DC0%0/1
'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
'Sisimai::SMTP::Command'->find($e->{'diagnosis'})
Truth table50%1/2
A
A= 'Sisimai::SMTP::Command'->find($e->{'diagnosis'})
Aresult
11
00
73  
74 16 ▶ if( defined $mhead->{'x-spasign'} && $mhead->{'x-spasign'} eq 'NG' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mhead->{'x-spasign'} and $mhead->{'x-spasign'} eq 'NG') { } 0 16 16
Condition33%1/3
defined $mhead->{"x-spasign"} and $mhead->{"x-spasign"} eq "NG"
!ll&&!rl&&r
1600
MC/DC0%0/2
defined $mhead->{"x-spasign"} and $mhead->{"x-spasign"} eq "NG"
defined $mhead->{"x-spasign"} $mhead->{"x-spasign"} eq "NG"
Truth table33%1/3
A and B
A= defined $mhead->{"x-spasign"}B= $mhead->{"x-spasign"} eq "NG"
ABresult
0X0
100
111
75 # Content-Type: text/plain; ..., X-SPASIGN: NG (spamghetti, au by KDDI)
76 # Filtered recipient returns message that include 'X-SPASIGN' header
77 0 $e->{'reason'} = $Sisimai::Eb::ReFILT;
78  
79 } else {
80 # There is no X-SPASIGN: header in the bounce message
81 # set "UserUnknown" when the remote server rejected after RCPT command.
82 16 ▶ $e->{'reason'} = $Sisimai::Eb::ReUSER if $e->{'command'} eq $Sisimai::Eb::CeRCPT;
Branch: 1 branch
BranchTrueFalseTotal
if $e->{"command"} eq $Sisimai::Eb::CeRCPT 0 16 16
83 }
84 }
85 16 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
86 }
87  
88 41 1;
89 __END__
« Sisimai/Lhost/V5sendmail.pm ↑ Summary Sisimai/Lhost/ApacheJames.pm »