| 1 | package Sisimai::Lhost::FML; | ||||||||||||||||||||||||||||
| 2 | 40 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'fml mailing list server/manager: https://www.fml.org/' }; | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | 903 | ▶ | sub inquire { | ||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=17 SCAR=28.8
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | # Detect an error from fml mailing list server/manager | ||||||||||||||||||||||||||||
| 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.22.3 | ||||||||||||||||||||||||||||
| 15 | 903 | my $class = shift; | |||||||||||||||||||||||||||
| 16 | 903 | ▶ | my $mhead = shift // return undef; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() // (return undef)
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 17 | 902 | ▶ | my $mbody = shift // return undef; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() // (return undef)
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 901 | ▶ | return undef unless defined $mhead->{'x-mlserver'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 10 | ▶ | return undef unless index($mhead->{'from'}, '-admin@') > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 10 | ▶ | return undef unless index($mhead->{'message-id'}, '.FML') > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 10 | require Sisimai::Eb; | |||||||||||||||||||||||||||
| 24 | 10 | state $boundaries = ['Original mail as follows:']; | |||||||||||||||||||||||||||
| 25 | 10 | state $errortitle = { | |||||||||||||||||||||||||||
| 26 | $Sisimai::Eb::ReFROM => [ | ||||||||||||||||||||||||||||
| 27 | ' are not member', | ||||||||||||||||||||||||||||
| 28 | 'NOT MEMBER article from ', | ||||||||||||||||||||||||||||
| 29 | 'reject mail ', | ||||||||||||||||||||||||||||
| 30 | 'Spam mail from a spammer is rejected', | ||||||||||||||||||||||||||||
| 31 | ], | ||||||||||||||||||||||||||||
| 32 | $Sisimai::Eb::RePROC => [ | ||||||||||||||||||||||||||||
| 33 | 'fml system error message', | ||||||||||||||||||||||||||||
| 34 | 'Loop Alert: ', | ||||||||||||||||||||||||||||
| 35 | 'Loop Back Warning: ', | ||||||||||||||||||||||||||||
| 36 | 'WARNING: UNIX FROM Loop', | ||||||||||||||||||||||||||||
| 37 | ], | ||||||||||||||||||||||||||||
| 38 | $Sisimai::Eb::ReSAFE => ['Security Alert'], | ||||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 10 | ▶ | my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
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)
| |||||||||||||||||||||||||||||
| 42 | 10 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||
| 43 | 10 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 10 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||
| 46 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||
| 47 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||
| 48 | 65 | ▶ | next unless length $e; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Duplicated Message-ID in <2ndml@example.com>. Original mail as follows: | ||||||||||||||||||||||||||||
| 51 | 40 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 40 | my $p1 = index($e, '<'); | |||||||||||||||||||||||||||
| 54 | 40 | my $p2 = rindex($e, '>'); | |||||||||||||||||||||||||||
| 55 | 40 | ▶ | if( $p1 > 0 && $p2 > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$p1 > 0 and $p2 > 0
MC/DC50%1/2
$p1 > 0 and $p2 > 0
$p1 > 0
$p2 > 0
Truth table66%2/3
A and B
A= $p1 > 0B= $p2 > 0
| |||||||||||||||||||||||||||||
| 56 | # You are not a member of this mailing list <neko-nyaan@example.org>. | ||||||||||||||||||||||||||||
| 57 | 10 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||
| 59 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||
| 60 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 10 | $v->{'recipient'} = substr($e, $p1 + 1, $p2 - $p1 - 1); | |||||||||||||||||||||||||||
| 63 | 10 | $v->{'diagnosis'} = $e; | |||||||||||||||||||||||||||
| 64 | 10 | $recipients++; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||
| 67 | # If you know the general guide of this list, please send mail with the mail body | ||||||||||||||||||||||||||||
| 68 | 30 | $v->{'diagnosis'} .= $e; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 10 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 10 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||
| 74 | # Error messages in the message body did not matched | ||||||||||||||||||||||||||||
| 75 | 10 | for my $f ( keys %$errortitle ) { | |||||||||||||||||||||||||||
| 76 | # Try to match with the Subject string | ||||||||||||||||||||||||||||
| 77 | 17 | ▶ | next unless grep { index($mhead->{'subject'}, $_) > -1 } $errortitle->{ $f }->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 10 | $e->{'reason'} = $f; | |||||||||||||||||||||||||||
| 79 | 10 | last; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 10 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 40 | 1; | |||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||