lib/Mail/Decency/Core/POEFilterSMTP.pm

filter: Statementstmt 51.2% 20 / 39 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 6 / 9 Podpod 100% 3 / 3 totaltotal 52.7% 29 / 55 CC 5 SCAR 18.2
CC
5
Cov
47%
get_one
12.0
put
12.0
new
2.0
CRAP 6.2
« lib/Mail/Decency/Core/POEForking/Postfix.pm ↑ Summary lib/Mail/Decency/Helper/Cache.pm »
1 package Mail::Decency::Core::POEFilterSMTP;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶use version 0.74; our $VERSION = qv( "v0.1.4" );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 ▶use base qw/ POE::Filter::Line /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 NAME
13  
14 Mail::Decency::Core::POEFilterSMTP
15  
16 =head1 DESCRIPTION
17  
18 Filters incoming data, based on POE::Filter::Line
19  
20 Each incoming line will be splitted into a trippled, where the first value contains the first word in uppercase, the second value the rest of the line (original case) and the last value the whole original line
21  
22 The first and second values are made for handling the SMTP protocol, whereas the last value has to assure the correct (upper/lower)case of the send DATA.
23  
24 This is based on: L<POE::Component::Server::SimpleSMTP> .. yes, it is reinventing the wheel, but somehow i have to understand this!
25  
26 =cut
27  
28 9 ▶use constant CRLF => qq/\x0D\x0A/; # RFC 2821, 2.3.7
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 =head1 METHODS
31  
32 =head2 new
33  
34 Create new filter, derived from POE::Filter::Line
35  
36 =cut
37  
38 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
39 0 my ($class) = @_;
40 0 return $class->SUPER::new( Literal => CRLF );
41 }
42  
43  
44 =head2 get_one
45  
46 Handle incoming lines
47  
48 =cut
49  
50 0 ▶sub get_one {
Subroutine get_one: not called CC=3 SCAR=24.8
Pod documented
51 0 my ($self) = shift;
52 0 my $lines = $self->SUPER::get_one( @_ );
53
54 0 foreach my $line ( @$lines ) {
55 0 my ($command, $data) = split( /\s+/, $line, 2 );
56 0 ▶ $data =~ s/\s+$// if $data;
Branch: 1 branch
BranchTrueFalseTotal
if $data 0 0 0
57 #print "IN> $line\n";
58 0 $line = [ uc( $command ), $data, $line. CRLF ];
59 }
60
61 0 return $lines;
62 }
63  
64  
65 =head2 put
66  
67 Handle output content
68  
69 =cut
70  
71 0 ▶sub put {
Subroutine put: not called CC=3 SCAR=24.8
Pod documented
72 0 my ($self, $lines) = @_;
73
74 0 my $code = shift @{$lines};
75
76 # return
77 # 250 OK
78 0 ▶ if ( $#$lines == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lines->$#* == 0) 0 0 0
79 0 return $self->SUPER::put( [ "$code @{$lines}" ] );
80 }
81
82 # return
83 # 250-something
84 # 250 OK
85 0 my @output;
86 0 push @output, "$code-$lines->[$_]" for 0 .. $#$lines - 1;
87 0 push @output, "$code $lines->[-1]";
88
89 0 return $self->SUPER::put( \@output );
90 }
91  
92  
93 =head1 AUTHOR
94  
95 Ulrich Kautz <uk@fortrabbit.de>
96  
97 =head1 COPYRIGHT
98  
99 Copyright (c) 2010 the L</AUTHOR> as listed above
100  
101 =head1 LICENCSE
102  
103 This library is free software and may be distributed under the same terms as perl itself.
104  
105 =cut
106  
107 9 1;
« lib/Mail/Decency/Core/POEForking/Postfix.pm ↑ Summary lib/Mail/Decency/Helper/Cache.pm »