File Coverage

lib/Sisimai/Reason/NotCompliantRFC.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 4 4 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 37 39 94.8


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NotCompliantRFC;
2 51     51   2762 use v5.26;
  51         146  
3 51     51   251 use strict;
  51         84  
  51         1232  
4 51     51   244 use warnings;
  51         80  
  51         10641  
5              
6 16     16 1 45 sub text { 'notcompliantrfc' }
7 4     4 0 19 sub description { "Email rejected due to non-compliance with RFC" }
8             sub match {
9             # Try to match that the given text and regular expressions
10             # @param [String] argv1 String to be matched with regular expressions
11             # @return [Integer] 0: Did not match
12             # 1: Matched
13             # @since v5.0.0
14 1061     1061 1 2913 my $class = shift;
15 1061   100     2582 my $argv1 = shift // return 0;
16              
17 1060         1199 state $index = [
18             "duplicate header",
19             "duplicated message-id",
20             "message is not rfc 5322 compliant",
21             "multiple addresses in from: header are not accepted",
22             "rfc 1035 violation",
23             "https://support.google.com/mail/?p=rfcmessagenoncompliant",
24             ];
25 1060 100       1846 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  6360         9554  
26 1043         2721 return 0;
27             }
28              
29             sub true {
30             # Whether the email is RFC compliant or not
31             # @param [Sisimai::Fact] argvs Object to be detected the reason
32             # @return [Integer] 1: RFC compliant
33             # 0: Is not RFC compliant
34             # @since v5.0.0
35             # @see http://www.ietf.org/rfc/rfc5322.txt
36 1061     1061 0 1652 my $class = shift;
37 1061   100     2567 my $argvs = shift // return 0;
38              
39 1060 100       2417 return 1 if $argvs->{'reason'} eq 'notcompliantrfc';
40 1059         3254 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
41             }
42              
43             1;
44             __END__