Filter/Module/BlankBody.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 31 CC 2 SCAR 11.5
CC
2
Cov
0%
match
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.1
1 #
2 # Courier::Filter::Module::BlankBody class
3 #
4 # (C) 2004-2008 Julian Mehnle <julian@mehnle.net>
5 # $Id: BlankBody.pm 210 2008-03-21 19:30:31Z julian $
6 #
7 ###############################################################################
8  
9 =head1 NAME
10  
11 Courier::Filter::Module::BlankBody - Blank-body message filter module for the
12 Courier::Filter framework
13  
14 =cut
15  
16 package Courier::Filter::Module::BlankBody;
17  
18 use warnings;
19 use strict;
20  
21 use base 'Courier::Filter::Module';
22  
23 use constant TRUE => (0 == 0);
24 use constant FALSE => not TRUE;
25  
26 =head1 SYNOPSIS
27  
28 use Courier::Filter::Module::BlankBody;
29  
30 my $module = Courier::Filter::Module::BlankBody->new(
31 response => $response_text,
32  
33 logger => $logger,
34 inverse => 0,
35 trusting => 0,
36 testing => 0,
37 debugging => 0
38 );
39  
40 my $filter = Courier::Filter->new(
41 ...
42 modules => [ $module ],
43 ...
44 );
45  
46 =head1 DESCRIPTION
47  
48 This class is a filter module class for use with Courier::Filter. It matches a
49 message if its body is blank or consists only of whitespace, which is a
50 frequent symptom of stupid spammers.
51  
52 =cut
53  
54 # Implementation:
55 ###############################################################################
56  
57 =head2 Constructor
58  
59 The following constructor is provided:
60  
61 =over
62  
63 =item B<new(%options)>: returns I<Courier::Filter::Module::BlankBody>
64  
65 Creates a new B<BlankBody> filter module.
66  
67 %options is a list of key/value pairs representing any of the following
68 options:
69  
70 =over
71  
72 =item B<response>
73  
74 A string that is to be returned literally as the match result in case of a
75 match. Defaults to B<< "Message body is blank" >>.
76  
77 =back
78  
79 All options of the B<Courier::Filter::Module> constructor are also supported.
80 Please see L<Courier::Filter::Module/"new"> for their descriptions.
81  
82 =back
83  
84 =head2 Instance methods
85  
86 See L<Courier::Filter::Module/"Instance methods"> for a description of the
87 provided instance methods.
88  
89 =cut
90  
91 sub match {
92 my ($self, $message) = @_;
93
94 return 'BlankBody: ' . ($self->{response} || 'Message body is blank')
95 if $message->body =~ /^\s*$/;
96
97 return undef;
98 # otherwise.
99 }
100  
101 =head1 SEE ALSO
102  
103 L<Courier::Filter::Module>, L<Courier::Filter::Overview>.
104  
105 For AVAILABILITY, SUPPORT, COPYRIGHT, and LICENSE information, see
106 L<Courier::Filter::Overview>.
107  
108 =head1 AUTHOR
109  
110 Julian Mehnle <julian@mehnle.net>
111  
112 =cut
113  
114 TRUE;