https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7724
Bug ID: 7724
Summary: [review] MIMEEval state not checked properly
Product: Spamassassin
Version: 3.4.2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: Plugins
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: Undefined
Trivial patch, RTC vote for 3.4.3 (+1 from me)
$pms->{mime_checked_attachments} should always be checked to run
_check_attachments, not some random variable someone might forget to add or
remove from internals.
--- MIMEEval.pm (revision 1861575)
+++ MIMEEval.pm (working copy)
@@ -117,7 +117,8 @@
sub check_for_ascii_text_illegal {
my ($self, $pms) = @_;
- $self->_check_attachments($pms) unless exists
$pms->{mime_ascii_text_illegal};
+ $self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{mime_ascii_text_illegal};
return ($pms->{mime_ascii_text_illegal} > 0);
}
@@ -143,7 +144,8 @@
# validate ratio?
return 0 unless ($ratio =~ /^\d{0,3}\.\d{1,3}$/);
- $self->_check_attachments($pms) unless exists
$pms->{mime_text_unicode_ratio};
+ $self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{mime_text_unicode_ratio};
return ($pms->{mime_text_unicode_ratio} >= $ratio);
}
@@ -178,7 +180,8 @@
sub check_for_mime {
my ($self, $pms, undef, $test) = @_;
- $self->_check_attachments($pms) unless exists $pms->{$test};
+ $self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{$test};
return $pms->{$test};
}
@@ -189,7 +192,8 @@
my $ctype = $pms->get('Content-Type');
return 1 if $ctype =~ m{^text/html}i;
- $self->_check_attachments($pms) unless exists $pms->{mime_body_html_count};
+ $self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{mime_body_html_count};
return ($pms->{mime_body_html_count} > 0);
}
@@ -200,7 +204,9 @@
my $ctype = $pms->get('Content-Type');
return 1 if $ctype =~ m{^text/html}i;
- $self->_check_attachments($pms) unless exists $pms->{mime_body_html_count};
+ $self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{mime_body_html_count};
+ return 0 unless exists $pms->{mime_body_text_count};
return ($pms->{mime_body_html_count} > 0 &&
$pms->{mime_body_text_count} == 0);
}
@@ -208,8 +214,8 @@
sub check_mime_multipart_ratio {
my ($self, $pms, undef, $min, $max) = @_;
- $self->_check_attachments($pms) unless exists
$pms->{mime_multipart_alternative};
-
+ $self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{mime_multipart_ratio};
return ($pms->{mime_multipart_ratio} >= $min &&
$pms->{mime_multipart_ratio} < $max);
}
@@ -517,6 +523,7 @@
my ($self, $pms, undef, $min) = @_;
$self->_check_attachments($pms) unless exists
$pms->{mime_checked_attachments};
+ return 0 unless exists $pms->{mime_qp_ratio};
my $qp_ratio = $pms->{mime_qp_ratio};
--
You are receiving this mail because:
You are the assignee for the bug.