"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Mail/SpamAssassin/Plugin/BodyEval.pm" between
Mail-SpamAssassin-3.4.4.tar.bz2 and Mail-SpamAssassin-3.4.5.tar.bz2

About: SpamAssassin is a mail filter that uses a wide range of heuristic tests on mail headers and body text to identify "spam" (also known as unsolicited commercial email) incl. Bayesian (statistical) spam filter and several internet-based realtime blacklists.

BodyEval.pm  (Mail-SpamAssassin-3.4.4.tar.bz2):BodyEval.pm  (Mail-SpamAssassin-3.4.5.tar.bz2)
skipping to change at line 49 skipping to change at line 49
bless ($self, $class); bless ($self, $class);
# the important bit! # the important bit!
$self->register_eval_rule("multipart_alternative_difference"); $self->register_eval_rule("multipart_alternative_difference");
$self->register_eval_rule("multipart_alternative_difference_count"); $self->register_eval_rule("multipart_alternative_difference_count");
$self->register_eval_rule("check_blank_line_ratio"); $self->register_eval_rule("check_blank_line_ratio");
$self->register_eval_rule("tvd_vertical_words"); $self->register_eval_rule("tvd_vertical_words");
$self->register_eval_rule("check_stock_info"); $self->register_eval_rule("check_stock_info");
$self->register_eval_rule("check_body_length"); $self->register_eval_rule("check_body_length");
$self->register_eval_rule("plaintext_body_length");
$self->register_eval_rule("plaintext_sig_length");
$self->register_eval_rule("plaintext_body_sig_ratio");
return $self; return $self;
} }
sub multipart_alternative_difference { sub multipart_alternative_difference {
my ($self, $pms, $fulltext, $min, $max) = @_; my ($self, $pms, $fulltext, $min, $max) = @_;
$self->_multipart_alternative_difference($pms) unless (exists $pms->{madiff}); $self->_multipart_alternative_difference($pms) unless (exists $pms->{madiff});
if (($min == 0 || $pms->{madiff} > $min) && if (($min == 0 || $pms->{madiff} > $min) &&
($max eq "undef" || $pms->{madiff} <= $max)) { ($max eq "undef" || $pms->{madiff} <= $max)) {
skipping to change at line 295 skipping to change at line 299
sub check_body_length { sub check_body_length {
my ($self, $pms, undef, $min) = @_; my ($self, $pms, undef, $min) = @_;
my $body_length = $pms->{msg}->{pristine_body_length}; my $body_length = $pms->{msg}->{pristine_body_length};
dbg("eval: body_length - %s - check for min of %s", $body_length, $min); dbg("eval: body_length - %s - check for min of %s", $body_length, $min);
return (defined $body_length && $body_length <= $min) ? 1 : 0; return (defined $body_length && $body_length <= $min) ? 1 : 0;
} }
# For plain text parts with a signature delimiter, evaluate the ratio and
# lengths (in bytes) of the body and signature parts.
#
# Arguments: min and (optional) max value
#
# body __SIG_RATIO_EXCESSIVE eval:plaintext_body_sig_ratio('0','0.5')
sub plaintext_body_length {
my ($self, $pms, undef, $min, $max) = @_;
$self->_plaintext_body_sig_ratio($pms);
my $len = $pms->{plaintext_body_sig_ratio}->{body_length};
return ( defined $len
&& $len >= $min
&& (defined $max ? $len <= $max : 1) ) ? 1 : 0;
}
sub plaintext_sig_length {
my ($self, $pms, undef, $min, $max) = @_;
$self->_plaintext_body_sig_ratio($pms);
my $len = $pms->{plaintext_body_sig_ratio}->{sig_length};
return ( defined $len
&& $len >= $min
&& (defined $max ? $len <= $max : 1) ) ? 1 : 0;
}
sub plaintext_body_sig_ratio {
my ($self, $pms, undef, $min, $max) = @_;
$self->_plaintext_body_sig_ratio($pms);
my $len = $pms->{plaintext_body_sig_ratio}->{ratio};
return ( defined $len
&& $len >= $min
&& (defined $max ? $len <= $max : 10**6) ) ? 1 : 0;
}
sub _plaintext_body_sig_ratio {
my ($self, $pms) = @_;
return if exists $pms->{plaintext_body_sig_ratio};
$pms->{plaintext_body_sig_ratio} = {};
# Find the first text/plain MIME part.
# Naive approach. This should commonly match the text/plain part we want,
# but could be enhanced to better cope with complex MIME structures.
my $part = ($pms->{msg}->find_parts(qr/^text\/plain/))[0];
return unless defined $part;
# Decode if necessary, do not render or alter whitespace.
my $text = $part->decode();
# Find the last occurence of a signature delimiter and get the body and
# signature lengths.
my ($len_b, $len_s) = map { length } $text =~ /(^|.*\n)-- \n(.*?)$/s;
if (! defined $len_b) { # no sig marker, all body
$len_b = length $text;
$len_s = 0;
}
$pms->{plaintext_body_sig_ratio}->{body_length} = $len_b;
$pms->{plaintext_body_sig_ratio}->{sig_length} = $len_s;
$pms->{plaintext_body_sig_ratio}->{ratio} = $len_s ? $len_b/$len_s : 10**6;
return 1;
}
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# capability checks for "if can()": # capability checks for "if can()":
# #
sub has_check_body_length { 1 } sub has_check_body_length { 1 }
sub has_plaintext_body_sig_ratio { 1 }
1; 1;
 End of changes. 3 change blocks. 
0 lines changed or deleted 84 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)