Sisimai/Lhost/GMX.pm

filter: Statementstmt 100% 45 / 45 Branchbran 81.8% 18 / 22 Conditioncond 80.0% 12 / 15 MC/DCmcdc 62.5% 5 / 8 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 89.8% 88 / 98 CC 19 SCAR 27.4
CC
19
Cov
91%
inquire
19.4
BEGIN
1.0
BEGIN
1.0
CRAP 15.5
« Sisimai/Lhost/X3.pm ↑ Summary Sisimai/SMTP/Reply.pm »
1 package Sisimai::Lhost::GMX;
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 { 'GMX: https://gmx.net/' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 925 ▶sub inquire {
Subroutine inquire: called CC=19 SCAR=29.6
Pod documented
9 # Detect an error from GMX and mail.com
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.1.4
15 925 my $class = shift;
16 925 ▶ my $mhead = shift // return undef; return undef unless defined $mhead->{'x-gmx-antispam'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mhead->{"x-gmx-antispam"} 903 21 924
Condition100%2/2
shift() // (return undef)
l!l
9241
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 21 ▶ my $mbody = shift // return undef;
Condition50%1/2
shift() // (return undef)
l!l
210
MC/DC0%0/1
shift() // (return undef)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
18  
19 # Envelope-To: <kijitora@mail.example.com>
20 # X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3;
21 # X-GMX-Antivirus: 0 (no virus found)
22 # X-UI-Out-Filterresults: unknown:0;
23 21 require Sisimai::SMTP::Command;
24 21 state $indicators = __PACKAGE__->INDICATORS;
25 21 state $boundaries = ['--- The header of the original message is following. ---'];
26 21 state $startingof = {'message' => ['This message was created automatically by mail delivery software']};
27  
28 21 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 21 21
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
210
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 21 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
30 21 my $readcursor = 0; # (Integer) Points the current cursor position
31 21 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
32  
33 21 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 230 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 21 209 230
37 # Beginning of the bounce message or message/delivery-status part
38 21 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $startingof->{"message"}[0]) == 0 21 0 21
39 21 next;
40 }
41 209 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 47 162 209
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
047162
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
42  
43 # This message was created automatically by mail delivery software.
44 #
45 # A message that you sent could not be delivered to one or more of
46 # its recipients. This is a permanent error. The following address
47 # failed:
48 #
49 # "shironeko@example.jp":
50 # SMTP error from remote server after RCPT command:
51 # host: mx.example.jp
52 # 5.1.1 <shironeko@example.jp>... User Unknown
53 162 $v = $dscontents->[-1];
54  
55 162 ▶ if( index($e, '@') > 1 && (index($e, '"') == 0 || index($e, '<') == 0) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (index($e, '@') > 1 and index($e, '"') == 0 || index($e, '<') == 0) { } 26 136 162
elsif (index($e, 'SMTP error ') == 0) { } 21 115 136
elsif (index($e, 'host: ') == 0) { } 21 94 115
Condition100%6/6
index($e, "\@") > 1 and index($e, "\"") == 0 || index($e, "<") == 0
!ll&&!rl&&r
1152126
index($e, "\"") == 0 or index($e, "<") == 0
l!l&&r!l&&!r
21521
MC/DC100%3/3
index($e, "\@") > 1 and index($e, "\"") == 0 || index($e, "<") == 0
index($e, "\@") > 1 index($e, "\"") == 0 index($e, "<") == 0
Truth table100%4/4
A and B or C
A= index($e, "\@") > 1B= index($e, "\"") == 0C= index($e, "<") == 0
ABCresult
0XX0
1000
11X1
1011
56 # "shironeko@example.jp":
57 # ---- OR ----
58 # <kijitora@6jo.example.co.jp>
59 #
60 # Reason:
61 # delivery retry timeout exceeded
62 26 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 5 21 26
63 # There are multiple recipient addresses in the message body.
64 5 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
65 5 $v = $dscontents->[-1];
66 }
67 26 $v->{'recipient'} = Sisimai::Address->s3s4($e);
68 26 $recipients++;
69  
70 } elsif( index($e, 'SMTP error ') == 0 ) {
71 # SMTP error from remote server after RCPT command:
72 21 $v->{'command'} = Sisimai::SMTP::Command->find($e);
73  
74 } elsif( index($e, 'host: ') == 0 ) {
75 # host: mx.example.jp
76 21 $v->{'rhost'} = substr($e, 6, );
77  
78 } else {
79 # Get error messages
80 94 ▶ next unless $e;
Branch: 1 branch
BranchTrueFalseTotal
unless $e 0 94 94
81 94 $v->{'diagnosis'} .= $e." ";
82 }
83 }
84 21 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 21 21
85 21 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
86 }
87  
88 41 1;
89 __END__
« Sisimai/Lhost/X3.pm ↑ Summary Sisimai/SMTP/Reply.pm »