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 47     47   2924 use v5.26;
  47         565  
3 47     47   275 use strict;
  47         90  
  47         1243  
4 47     47   273 use warnings;
  47         106  
  47         18481  
5              
6 40     40 1 143 sub text { 'contenterror' }
7 4     4 0 16 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 1245     1245 1 2689 my $class = shift;
15 1245   100     4653 my $argv1 = shift // return 0;
16              
17 1244         2460 state $index = [
18             "executable files are not allowed in compressed files",
19             "header error",
20             "header size exceeds maximum permitted",
21             "illegal attachment on your message",
22             "improper use of 8-bit data in message header",
23             "it has a potentially executable attachment",
24             "message contain invalid mime headers",
25             "message contain improperly-formatted binary content",
26             "message contain text that uses unnecessary base64 encoding",
27             "message header size, or recipient list, exceeds policy limit",
28             "message mime complexity exceeds the policy maximum",
29             "message was blocked because its content presents a potential", # https://support.google.com/mail/answer/6590
30             "routing loop detected -- too many received: headers",
31             "we do not accept messages containing images or other attachments",
32             ];
33 1244 100       2721 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  17416         35384  
34 1219         5449 return 0;
35             }
36              
37             sub true {
38             # Rejected email due to header format of the email
39             # @param [Sisimai::Fact] argvs Object to be detected the reason
40             # @return [Integer] 1: rejected due to content error
41             # 0: is not content error
42             # @see http://www.ietf.org/rfc/rfc2822.txt
43 962     962 0 2072 my $class = shift;
44 962   100     2924 my $argvs = shift // return 0;
45              
46 961         22924 require Sisimai::Reason::SpamDetected;
47 961 50       4141 return 1 if $argvs->{'reason'} eq 'contenterror';
48 961 100       6879 return 0 if Sisimai::Reason::SpamDetected->true($argvs);
49 914 100 100     4227 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'contenterror';
50 899         4895 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
51             }
52              
53             1;
54             __END__