Sisimai/Lhost/X6.pm

filter: Statementstmt 94.5% 52 / 55 Branchbran 79.1% 19 / 24 Conditioncond 83.3% 10 / 12 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 88.6% 94 / 106 CC 20 SCAR 28.3
CC
20
Cov
89%
inquire
20.8
BEGIN
1.0
BEGIN
1.0
CRAP 16.9
« Sisimai/Lhost/Activehunter.pm ↑ Summary Sisimai/RFC2045.pm »
1 package Sisimai::Lhost::X6;
2 35 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 35 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'Unknown MTA #6' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 868 ▶sub inquire {
Subroutine inquire: called CC=20 SCAR=30.4
Pod documented
9 # Detect an error from Unknown MTA #6
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.25.6
15 868 my $class = shift;
16 868 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8671
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 867 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8661
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18  
19 866 ▶ return undef unless $mhead->{'subject'};
Branch: 1 branch
BranchTrueFalseTotal
unless $mhead->{"subject"} 18 848 866
20 848 ▶ return undef if index($mhead->{'subject'}, 'There was an error sending your mail') != 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"subject"}, "There was an error sending your mail") != 0 837 11 848
21  
22 11 state $indicators = __PACKAGE__->INDICATORS;
23 11 state $boundaries = ['The attachment contains the original mail headers'];
24 11 state $startingof = {'message' => ['We had trouble delivering your message. Full details follow:']};
25  
26 11 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 11 11
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
110
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
27 11 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
28 11 my $readcursor = 0; # (Integer) Points the current cursor position
29 11 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
30  
31 11 for my $e ( split("\n", $emailparts->[0]) ) {
32 # Read error messages and delivery status lines from the head of the email to the previous
33 # line of the beginning of the original message.
34 110 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 33 77 110
35 # Beginning of the bounce message or message/delivery-status part
36 33 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $startingof->{"message"}[0]) == 0 11 22 33
37 33 next;
38 }
39 77 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 33 44 77
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
03344
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
40  
41 # We had trouble delivering your message. Full details follow:
42 #
43 # Subject: 'Nyaan'
44 # Date: 'Thu, 29 Apr 2012 23:34:45 +0000'
45 #
46 # 1 error(s):
47 #
48 # SMTP Server <mta2.example.jp> rejected recipient <kijitora@examplejp>
49 # (Error following RCPT command). It responded as follows: [550 5.1.1 User unknown]
50 44 $v = $dscontents->[-1];
51 44 my $p1 = index($e, 'The following recipients returned permanent errors: ');
52 44 my $p2 = index($e, 'SMTP Server <');
53 44 ▶ if( $p1 == 0 || $p2 == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p1 == 0 or $p2 == 0) 11 33 44
Condition100%3/3
$p1 == 0 or $p2 == 0
l!l&&r!l&&!r
6533
MC/DC100%2/2
$p1 == 0 or $p2 == 0
$p1 == 0 $p2 == 0
Truth table100%3/3
A or B
A= $p1 == 0B= $p2 == 0
ABresult
1X1
011
000
54 # SMTP Server <mta2.example.jp> rejected recipient <kijitora@examplejp>
55 # The following recipients returned permanent errors: neko@example.jp.
56 11 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 11 11
57 # There are multiple recipient addresses in the message body.
58 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
59 0 $v = $dscontents->[-1];
60 }
61 11 ▶ if( $p1 == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p1 == 0) { } 6 5 11
elsif ($p2 == 0) { } 5 0 5
62 # The following recipients returned permanent errors: neko@example.jp.
63 6 $p1 = index($e, 'errors: ');
64 6 $p2 = index($e, ' ', $p1 + 8);
65 6 $v->{'recipient'} = Sisimai::Address->s3s4(substr($e, $p1 + 8, $p2 - $p1 - 8));
66  
67 } elsif( $p2 == 0 ) {
68 # SMTP Server <mta2.example.jp> rejected recipient <kijitora@example.jp>
69 5 $p1 = rindex($e, '<');
70 5 $p2 = rindex($e, '>');
71 5 $v->{'recipient'} = Sisimai::Address->s3s4(substr($e, $p1, $p2 - $p1));
72  
73 } else {
74 0 next;
75 }
76 11 $v->{'diagnosis'} = $e;
77 11 $recipients++;
78 }
79 }
80 11 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 11 11
81  
82 11 require Sisimai::SMTP::Command;
83 11 for my $e ( @$dscontents ) {
84 # Get the last SMTP command from the error message
85 11 ▶ if( my $cv = Sisimai::SMTP::Command->find($e->{'diagnosis'}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cv = "Sisimai::SMTP::Command"->find($e->{"diagnosis"})) 11 0 11
86 # ...(Error following RCPT command).
87 11 $e->{'command'} = $cv;
88 }
89 }
90 11 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
91 }
92  
93 35 1;
94 __END__
« Sisimai/Lhost/Activehunter.pm ↑ Summary Sisimai/RFC2045.pm »