| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Mail/Salsa/Action/Post.pm | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Last Modification: Wed Mar 17 19:11:38 WET 2010 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2010 Henrique Dias <henrique.ribeiro.dias@gmail.com>. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | package Mail::Salsa::Action::Post; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use 5.008000; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 17 | #use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use SelfLoader; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Mail::Salsa::Utils qw(file_path create_file generate_id); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Mail::Salsa::Logs qw(logs debug); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Mail::Salsa::Archive qw(archive_msg); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use MIME::QuotedPrint qw(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # This allows declaration use Mail::Salsa ':all'; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # will save memory. | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | our %EXPORT_TAGS = ( 'all' => [ qw() ] ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | our @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | SelfLoader->load_stubs(); | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $self = {@_}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | bless ($self, $class); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $self->process_msg(); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub process_msg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_msg: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my ($name, $domain) = split(/\@/, $self->{'list'}); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | unless($self->check_restrict('restrict.txt', $self->{'headers'}->{'0.0'}->{'received'}, [])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||||||||||||||||||||||||
| 54 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | timeout => $self->{'timeout'}, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | label => "PERMISSION_DENY", | ||||||||||||||||||||||||||||||||||||||||||
| 57 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | vars => { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | from => "$name\-owner\@$domain", | ||||||||||||||||||||||||||||||||||||||||||
| 60 | to => $self->{'from'}, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | list => $self->{'list'}, | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $self->logs(join("", "[permission deny] from: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if($self->{'config'}->{'max_message_size'} && (((-s $self->{'message'})/1024) > $self->{'config'}->{'max_message_size'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"config"}{"max_message_size"} and (-s $self->{"message"}) / 1024 > $self->{"config"}{"max_message_size"}
MC/DC0%0/2
$self->{"config"}{"max_message_size"} and (-s $self->{"message"}) / 1024 > $self->{"config"}{"max_message_size"}
$self->{"config"}{"max_message_size"}
(-s $self->{"message"}) / 1024 > $self->{"config"}{"max_message_size"}
Truth table0%0/3
A and B
A= $self->{"config"}{"max_message_size"}B= (-s $self->{"message"}) / 1024 > $self->{"config"}{"max_message_size"}
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||||||||||||||||||||||||
| 69 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | timeout => $self->{'timeout'}, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | label => "MAX_MESSAGE_SIZE", | ||||||||||||||||||||||||||||||||||||||||||
| 72 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | vars => { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | from => "$name\-owner\@$domain", | ||||||||||||||||||||||||||||||||||||||||||
| 75 | to => $self->{'from'}, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | list => $self->{'list'}, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | size => $self->{'config'}->{'max_message_size'}, | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->logs(join("", "[max message size exceed] from: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if(scalar(keys(%{$self->{'headers'}})) > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $attachfile = file_path($self->{'list'}, $self->{'list_dir'}, "attachments.txt"); | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $listfile = file_path($self->{'list'}, $self->{'list_dir'}, "list.txt"); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my ($code, $access, $mime_type) = ("", "allow", ""); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if(my $error = &generate_code($listfile, $attachfile, $self->{'from'}, $code)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->logs("[file] $error", "errors"); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | eval($code); | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $self->logs("[eval] $@", "errors"); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if($access eq "deny") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||||||||||||||||||||||||
| 98 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | timeout => $self->{'timeout'}, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | label => "NO_ATTACHMENTS", | ||||||||||||||||||||||||||||||||||||||||||
| 101 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | vars => { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | from => "$name\-owner\@$domain", | ||||||||||||||||||||||||||||||||||||||||||
| 104 | to => $self->{'from'}, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | list => $self->{'list'}, | |||||||||||||||||||||||||||||||||||||||||
| 106 | mime_type => $mime_type, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->logs(join("", "[deny attachment] mime-type: $mime_type from: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $self->setup_stamp() if($self->{'config'}->{'stamp'} eq "y"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | my $reply = ($self->{'headers'}->{'0.0'}->{'subject'}->{'value'} =~ /^Re: /i) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $bounce = $self->check4bounces(); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $human = $self->setup_msg(); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $human = 0 unless($self->{'stamp'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if($bounce == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | # debug and test | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->logs(join("", "[been-there] from: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 123 | ▶ | } elsif($bounce && $self->{'config'}->{'accept_bounces'} eq "n") { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$bounce and $self->{"config"}{"accept_bounces"} eq "n"
MC/DC0%0/2
$bounce and $self->{"config"}{"accept_bounces"} eq "n"
$bounce
$self->{"config"}{"accept_bounces"} eq "n"
Truth table0%0/3
A and B
A= $bounceB= $self->{"config"}{"accept_bounces"} eq "n"
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||||||||||||||||||||||||
| 125 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | timeout => $self->{'timeout'}, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | label => "DONT_BOUNCE", | ||||||||||||||||||||||||||||||||||||||||||
| 128 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | vars => { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | from => "$name\-owner\@$domain", | ||||||||||||||||||||||||||||||||||||||||||
| 131 | to => $self->{'from'}, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | list => $self->{'list'}, | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->logs(join("", "[bounce] from: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 136 | ▶ | } elsif($self->{'stamp'} && !$human) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"stamp"} and not $human
MC/DC0%0/2
$self->{"stamp"} and not $human
$self->{"stamp"}
not $human
Truth table0%0/3
A and not(B)
A= $self->{"stamp"}B= not $human
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | Mail::Salsa::Utils::tplsendmail( | ||||||||||||||||||||||||||||||||||||||||||
| 138 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | timeout => $self->{'timeout'}, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | label => "MAILSTAMP", | ||||||||||||||||||||||||||||||||||||||||||
| 141 | lang => $self->{'config'}->{'language'}, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | vars => { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | from => "$name\-owner\@$domain", | ||||||||||||||||||||||||||||||||||||||||||
| 144 | to => $self->{'from'}, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | list => $self->{'list'}, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | stamp => $self->{'stamp'} | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->logs(join("", "[sent stamp] to: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->sendmail4all(); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $self->logs(join("", "[post message] from: ", $self->{'from'}), "list"); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $self->archive_msg() if($self->{'config'}->{'archive'} eq "y"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | unlink($self->{'message'}); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub check4bounces { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check4bounces: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $bounce = 1; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $list = $self->{'list'}; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | $bounce = 0 if(lc($self->{'headers'}->{'0.0'}->{'to'}) =~ /\b$list\b/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $bounce = 0 if(exists($self->{'headers'}->{'0.0'}->{'cc'}) && lc($self->{'headers'}->{'0.0'}->{'cc'}) =~ /\b$list\b/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"headers"}{"0.0"}{"cc"} and lc($self->{"headers"}{"0.0"}{"cc"}) =~ /\b$list\b/
MC/DC0%0/2
exists $self->{"headers"}{"0.0"}{"cc"} and lc($self->{"headers"}{"0.0"}{"cc"}) =~ /\b$list\b/
exists $self->{"headers"}{"0.0"}{"cc"}
lc($self->{"headers"}{"0.0"}{"cc"}) =~ /\b$list\b/
Truth table0%0/3
A and B
A= exists $self->{"headers"}{"0.0"}{"cc"}B= lc($self->{"headers"}{"0.0"}{"cc"}) =~ /\b$list\b/
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $bounce = 2 if(exists($self->{'headers'}->{'0.0'}->{'x-been-there'}) && $self->{'headers'}->{'0.0'}->{'x-been-there'} eq $self->{'list'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"headers"}{"0.0"}{"x-been-there"} and $self->{"headers"}{"0.0"}{"x-been-there"} eq $self->{"list"}
MC/DC0%0/2
exists $self->{"headers"}{"0.0"}{"x-been-there"} and $self->{"headers"}{"0.0"}{"x-been-there"} eq $self->{"list"}
exists $self->{"headers"}{"0.0"}{"x-been-there"}
$self->{"headers"}{"0.0"}{"x-been-there"} eq $self->{"list"}
Truth table0%0/3
A and B
A= exists $self->{"headers"}{"0.0"}{"x-been-there"}B= $self->{"headers"}{"0.0"}{"x-been-there"} eq $self->{"list"}
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return($bounce); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub setup_stamp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_stamp: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $sfile = file_path($self->{'list'}, $self->{'list_dir'}, 'stamp.txt'); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my ($number, $letter) = ($self->{'config'}->{'stamp_life'} =~ /^(\d+)([dwmy])$/); | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $days = int(-M $sfile); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $newstamp = 0; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if($letter eq "d") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $newstamp = 1 if($days > $number); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | } elsif($letter eq "w") { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $newstamp = 1 if(int($days/7) > $number); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | } elsif($letter eq "m") { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $newstamp = 1 if(int($days/30) > $number); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | } elsif($letter eq "y") { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $newstamp = 1 if(int($days/365) > $number); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if($newstamp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->{'stamp'} = uc(generate_id(32)); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | create_file($sfile, join("", $self->{'stamp'}, "\n"), 0600); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | } else { $self->{'stamp'} = Mail::Salsa::Utils::get_key($sfile); } | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub exist_subscriber { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exist_subscriber: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $string = shift || return(0); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return 0)
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $exist = 0; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | open(MLIST, "<", $file) or return("$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | while(<MLIST>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | next if(/^[\#\x0d\x0a]/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if(/\b$string\b/) { $exist = 1; last; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | close(MLIST); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return($exist); | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub generate_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_code: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $listfile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $attachfile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $from_addr = shift; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $_[0] .= <<ENDCODE; | |||||||||||||||||||||||||||||||||||||||||
| 217 | for my \$part (keys(\%{\$self->{'headers'}})) { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | \$mime_type = \$self->{'headers'}->{\$part}->{'content-type'}->{'value'}; | ||||||||||||||||||||||||||||||||||||||||||
| 219 | local \$_ = \$mime_type; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | next if(index(\$_, \"multipart\/\") > -1); | ||||||||||||||||||||||||||||||||||||||||||
| 221 | ENDCODE | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $subscriber = 0; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | open(ATTACHMENT, "<", $attachfile) or return("$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | while(<ATTACHMENT>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | next if(/^[\#\x0d\x0a]/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my ($policy, $mime, $addr) = /^(\w+) +(\w+\/[\w\.\-\+]+) +from +(\S+)[\x0d\x0a]+/; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if($addr eq "subscribers") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | unless($subscriber) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $subscriber = &exist_subscriber($listfile, $from_addr); | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $subscriber = -1 unless($subscriber); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if($subscriber > 0) { $addr = $from_addr; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | else { next; } | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $mime =~ s{any(?=\/)}{\[\\w\\+\\-\\.\]\+}g; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $mime =~ s{(?<=\/)any}{\[\\w\\+\\-\\.\]\+}g; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $mime =~ s{\/}{\\\/}; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $addr =~ s/\@/\\\@/g; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $addr =~ s/\./\\\./g; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $part = ($addr eq "any") ? "" : " (\$self-\>{\'from\'} =~ /$addr\$/) and"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $keyword = $policy eq "deny" ? "last" : "next"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $_[0] .= "\t/\^$mime\$/ and$part \$access = \"$policy\", $keyword;\n"; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | close(ATTACHMENT); | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $_[0] .= "}\n"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub sendmail4all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sendmail4all: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my ($name, $domain) = split(/\@/, $self->{'list'}); | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $listfile = file_path($self->{'list'}, $self->{'list_dir'}, "list.txt"); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | (my $outfile = $self->{'message'}) =~ s/\.msg$/\.out/; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my $refsub = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | open(FILE, "<", $outfile) or die("$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | while(<FILE>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | s{^\.}{\.\.}; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | print $handle $_; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | close(FILE); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 265 | my $sm = Mail::Salsa::Sendmail->new( | ||||||||||||||||||||||||||||||||||||||||||
| 266 | smtp_server => $self->{'smtp_server'}, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | timeout => $self->{'timeout'}, | |||||||||||||||||||||||||||||||||||||||||
| 268 | smtp_port => 25, | ||||||||||||||||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $sm->everything( | |||||||||||||||||||||||||||||||||||||||||
| 271 | mail_from => "$name\-return\@$domain", | ||||||||||||||||||||||||||||||||||||||||||
| 272 | list_file => $listfile, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | data => $refsub | ||||||||||||||||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | unlink($outfile); | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub set_headers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_headers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $list = shift; | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my ($name, $domain) = split(/\@/, $list); | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $headers = <<"EOF"; | |||||||||||||||||||||||||||||||||||||||||
| 285 | X-Salsa-Version: 0.01 | ||||||||||||||||||||||||||||||||||||||||||
| 286 | X-Been-There: $name\@$domain | ||||||||||||||||||||||||||||||||||||||||||
| 287 | Precedence: bulk | ||||||||||||||||||||||||||||||||||||||||||
| 288 | List-Help: <mailto:$name-help\@$domain?subject=help\> | ||||||||||||||||||||||||||||||||||||||||||
| 289 | List-Unsubscribe: <mailto:$name-unsubscribe\@$domain?subject=unsubscribe\> | ||||||||||||||||||||||||||||||||||||||||||
| 290 | List-Subscribe: <mailto:$name-subscribe\@$domain?subject=subscribe\> | ||||||||||||||||||||||||||||||||||||||||||
| 291 | List-Admin: <mailto:$name-admin\@$domain\> | ||||||||||||||||||||||||||||||||||||||||||
| 292 | List-Post: \<mailto:$name\@$domain\> | ||||||||||||||||||||||||||||||||||||||||||
| 293 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return($headers); | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub insert_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_text: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $encoding = shift; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | open(BANNER, "<", $file) or die("$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | while(local $_ = <BANNER>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my $line = ($encoding eq "quoted-printable") ? MIME::QuotedPrint::encode($_) : $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | print $handle $line; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | close(BANNER); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | print $handle "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return(); | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub check_encoding { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_encoding: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $encoding = shift || return(1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return 1)
MC/DC0%0/1
shift() || (return 1)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | return(length($encoding) == 0 ? 1 : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | $encoding eq "quoted-printable" ? 1 : | ||||||||||||||||||||||||||||||||||||||||||
| 318 | $encoding eq "7bit" ? 1 : | ||||||||||||||||||||||||||||||||||||||||||
| 319 | $encoding eq "8bit" ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub setup_msg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_msg: not called CC=39 SCAR=73.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my ($name, $domain) = split(/\@/, $self->{'list'}); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | (my $outfile = $self->{'message'}) =~ s/\.msg$/\.out/; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my ($headerfile, $footerfile, $encoding) = ("", "", ""); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if($self->{'config'}->{'header'} eq "y") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $headerfile = file_path($self->{'list'}, $self->{'list_dir'}, "header.txt"); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | (-e $headerfile && -s $headerfile) or $headerfile = ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $headerfile and -s $headerfile
MC/DC0%0/2
-e $headerfile and -s $headerfile
-e $headerfile
-s $headerfile
Truth table0%0/3
A and B
A= -e $headerfileB= -s $headerfile
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if($self->{'config'}->{'footer'} eq "y") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $footerfile = file_path($self->{'list'}, $self->{'list_dir'}, "footer.txt"); | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | (-e $footerfile && -s $footerfile) or $footerfile = ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $footerfile and -s $footerfile
MC/DC0%0/2
-e $footerfile and -s $footerfile
-e $footerfile
-s $footerfile
Truth table0%0/3
A and B
A= -e $footerfileB= -s $footerfile
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | my $boundary = exists($self->{'headers'}->{'0.0'}->{'content-type'}->{'boundary'}) ? $self->{'headers'}->{'0.0'}->{'content-type'}->{'boundary'} : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my ($tree, $count) = $boundary ? ("0.0.0", 0) : ("0.0", 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if($headerfile || $footerfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$headerfile or $footerfile
MC/DC0%0/2
$headerfile or $footerfile
$headerfile
$footerfile
Truth table0%0/3
A or B
A= $headerfileB= $footerfile
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if(exists($self->{'headers'}->{$tree}->{'content-type'}->{'value'}) && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"headers"}{$tree}{"content-type"}{"value"} and $self->{"headers"}{$tree}{"content-type"}{"value"} eq "text/plain"
MC/DC0%0/2
exists $self->{"headers"}{$tree}{"content-type"}{"value"} and $self->{"headers"}{$tree}{"content-type"}{"value"} eq "text/plain"
exists $self->{"headers"}{$tree}{"content-type"}{"value"}
$self->{"headers"}{$tree}{"content-type"}{"value"} eq "text/plain"
Truth table0%0/3
A and B
A= exists $self->{"headers"}{$tree}{"content-type"}{"value"}B= $self->{"headers"}{$tree}{"content-type"}{"value"} eq "text/plain"
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | $self->{'headers'}->{$tree}->{'content-type'}->{'value'} eq "text/plain") { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if(exists($self->{'headers'}->{$tree}->{'content-transfer-encoding'}->{'value'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $encoding = $self->{'headers'}->{$tree}->{'content-transfer-encoding'}->{'value'}; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $encoding = $footerfile = $headerfile = "" unless(&check_encoding($encoding)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | } else { $footerfile = $headerfile = ""; } | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | my $stamp = $self->{'stamp'} || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'stamp'} || ''
MC/DC0%0/1
$self->{'stamp'} || ''
$self->{'stamp'}
Truth table0%0/2
A
A= $self->{'stamp'}
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $prefix = $self->{'config'}->{'prefix'}; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my ($exist, $received, $headers, $topheaders) = (0, 1, 1, 1); | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | open(INFILE, "<", $self->{'message'}) or die("$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | open(OUTFILE, ">", $outfile) or die("$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | select(OUTFILE); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | while(<INFILE>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if($headers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if($topheaders) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | next if(&check_headers($_)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | s/^Subject: (.+)/Subject: $prefix $1/o if($prefix && index($_, $prefix, 0) == -1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$prefix and index($_, $prefix, 0) == -1
MC/DC0%0/2
$prefix and index($_, $prefix, 0) == -1
$prefix
index($_, $prefix, 0) == -1
Truth table0%0/3
A and B
A= $prefixB= index($_, $prefix, 0) == -1
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | $received = 0 if($received == 1 && !(/^(X-)?Received: / || /^[ \t]+/)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$received == 1 and not /^(X-)?Received: / || /^[ \t]+/
/^(X-)?Received: / || /^[ \t]+/
MC/DC0%0/3
$received == 1 and not /^(X-)?Received: / || /^[ \t]+/
$received == 1
/^(X-)?Received: /
/^[ \t]+/
Truth table0%0/4
A and not(B || C)
A= $received == 1B= /^(X-)?Received: /C= /^[ \t]+/
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if($received == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | print OUTFILE &set_headers($self->{'list'}); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $received = -1; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | $headers = 0 if(/^[\n\r]$/o); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $topheaders = 0; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $exist = 1 if(s/\b$stamp\b//og); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if($headerfile || $footerfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$headerfile or $footerfile
MC/DC0%0/2
$headerfile or $footerfile
$headerfile
$footerfile
Truth table0%0/3
A or B
A= $headerfileB= $footerfile
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if($headerfile && $count == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$headerfile and $count == 1
MC/DC0%0/2
$headerfile and $count == 1
$headerfile
$count == 1
Truth table0%0/3
A and B
A= $headerfileB= $count == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | &insert_text(\*OUTFILE, $headerfile, $encoding); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $headerfile = ""; | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if($boundary && /^--$boundary/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$boundary and /^--$boundary/
MC/DC0%0/2
$boundary and /^--$boundary/
$boundary
/^--$boundary/
Truth table0%0/3
A and B
A= $boundaryB= /^--$boundary/
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $headers = 1; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if($footerfile && $count == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$footerfile and $count == 2
MC/DC0%0/2
$footerfile and $count == 2
$footerfile
$count == 2
Truth table0%0/3
A and B
A= $footerfileB= $count == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | &insert_text(\*OUTFILE, $footerfile, $encoding); | |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $footerfile = ""; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | print OUTFILE $_; | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | &insert_text(\*OUTFILE, $footerfile, $encoding) if($footerfile); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | close(OUTFILE); | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | close(INFILE); | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | select(STDOUT); | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return($exist); | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | sub check_restrict { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_restrict: not called CC=25 SCAR=64.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $thisfile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $receiveds = shift; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | my $array = shift || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $file = file_path($self->{'list'}, $self->{'list_dir'}, $thisfile); | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | (-s $file) or return(1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $count = scalar(@{$array}); | |||||||||||||||||||||||||||||||||||||||||
| 405 | ### ["policy", "address", "action", "network", "stamp"] ### | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | $array = ["", "", "", "", ""] unless($count); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $netok = 0; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | open(FILE, "<", $file) or return(1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | while(<FILE>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | next if(/^[\#\n\r]+/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if($count) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my ($addr) = (/\<?([^\@\<\>]+\@[^\@\<\>]+)\>?/); | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $array->[1] = $addr; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | (@{$array}) = (/^(allow|deny) +(\S+) +to +(post|bounce|proceed) +from +(localnet|anywhere)( +with(out)? +stamp)?/); | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if($array->[1] eq "subscribers") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $array->[1] = ""; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $netok = $self->check_restrict('list.txt', $receiveds, $array); | |||||||||||||||||||||||||||||||||||||||||
| 422 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $self->{'config'}->{'accept_bounces'} = ($self->{'config'}->{'stamp'} = "n"); | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my $address = $array->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | if($address eq "any") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | last if($array->[0] eq "deny" and $array->[3] eq "anywhere"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$array->[0] eq "deny" and $array->[3] eq "anywhere"
MC/DC0%0/2
$array->[0] eq "deny" and $array->[3] eq "anywhere"
$array->[0] eq "deny"
$array->[3] eq "anywhere"
Truth table0%0/3
A and B
A= $array->[0] eq "deny"B= $array->[3] eq "anywhere"
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $address = "\.+"; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if($self->{'from'} =~ /$address$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | $netok = ($array->[3] eq "anywhere") ? 1 : | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | ($array->[3] eq "localnet") ? &check_network($receiveds, $self->{'config'}->{'localnet'}) : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if(defined($array->[4]) && $array->[4]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $array->[4] and $array->[4]
MC/DC0%0/2
defined $array->[4] and $array->[4]
defined $array->[4]
$array->[4]
Truth table0%0/3
A and B
A= defined $array->[4]B= $array->[4]
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | $self->{'config'}->{'stamp'} = ($array->[0] eq "allow") ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | (($array->[4] =~ /^ +without +stamp/) ? "n" : "y") : | ||||||||||||||||||||||||||||||||||||||||||
| 436 | (($array->[4] =~ /^ +without +stamp/) ? "y" : "n"); | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | if($array->[2] eq "bounce" or $array->[2] eq "proceed") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$array->[2] eq "bounce" or $array->[2] eq "proceed"
MC/DC0%0/2
$array->[2] eq "bounce" or $array->[2] eq "proceed"
$array->[2] eq "bounce"
$array->[2] eq "proceed"
Truth table0%0/3
A or B
A= $array->[2] eq "bounce"B= $array->[2] eq "proceed"
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | $self->{'config'}->{'accept_bounces'} = ($array->[0] eq "allow") ? "y" : ($self->{'config'}->{'stamp'} eq "y") ? "y" : "n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | last if($netok); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | close(FILE); | |||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | return($netok); | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 451 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||