File Coverage

lib/Sisimai/Reason/ContentError.pm
Criterion Covered Total %
statement 23 23 100.0
branch 7 8 87.5
condition 6 6 100.0
subroutine 7 7 100.0
pod 2 4 50.0
total 45 48 93.7


line stmt bran cond sub pod time code
1             package Sisimai::Reason::ContentError;
2 49     49   2656 use v5.26;
  49         152  
3 49     49   203 use strict;
  49         70  
  49         1108  
4 49     49   166 use warnings;
  49         66  
  49         13512  
5              
6 40     40 1 89 sub text { 'contenterror' }
7 4     4 0 19 sub description { 'Email rejected due to a header format of the email' }
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 v4.0.0
14 1034     1034 1 2283 my $class = shift;
15 1034   100     2376 my $argv1 = shift // return 0;
16              
17 1033         1313 state $index = [
18             "charset not supported",
19             "executable files are not allowed in compressed files",
20             "header error",
21             "header size exceeds maximum permitted",
22             "illegal attachment on your message",
23             "improper use of 8-bit data in message header",
24             "it has a potentially executable attachment",
25             "message contain invalid mime headers",
26             "message contain improperly-formatted binary content",
27             "message contain text that uses unnecessary base64 encoding",
28             "message header size, or recipient list, exceeds policy limit",
29             "message mime complexity exceeds the policy maximum",
30             "message was blocked because its content presents a potential", # https://support.google.com/mail/answer/6590
31             "routing loop detected -- too many received: headers",
32             'too many "received" headers', # Exim/deliver.c:5425
33             "we do not accept messages containing images or other attachments",
34             ];
35 1033 100       1659 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  16528         19933  
36 1008         2850 return 0;
37             }
38              
39             sub true {
40             # Rejected email due to header format of the email
41             # @param [Sisimai::Fact] argvs Object to be detected the reason
42             # @return [Integer] 1: rejected due to content error
43             # 0: is not content error
44             # @see http://www.ietf.org/rfc/rfc2822.txt
45 1034     1034 0 1932 my $class = shift;
46 1034   100     2444 my $argvs = shift // return 0;
47              
48 1033         18502 require Sisimai::Reason::SpamDetected;
49 1033 50       3184 return 1 if $argvs->{'reason'} eq 'contenterror';
50 1033 100       5558 return 0 if Sisimai::Reason::SpamDetected->true($argvs);
51 986 100 100     4018 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'contenterror';
52 971         3779 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
53             }
54              
55             1;
56             __END__