michael@374: Index: lib/Mail/SpamAssassin/Dns.pm michael@374: --- lib/Mail/SpamAssassin/Dns.pm.orig 2010-03-16 15:49:21.000000000 +0100 michael@374: +++ lib/Mail/SpamAssassin/Dns.pm 2011-02-08 16:03:06.000000000 +0100 michael@374: @@ -754,7 +754,7 @@ michael@374: dbg("dns: entering helper-app run mode"); michael@374: $self->{old_slash} = $/; # Razor pollutes this michael@374: %{$self->{old_env}} = (); michael@374: - if ( defined %ENV ) { michael@374: + if (%ENV) { michael@374: # undefined values in %ENV can result due to autovivification elsewhere, michael@374: # this prevents later possible warnings when we restore %ENV michael@374: while (my ($key, $value) = each %ENV) { michael@374: Index: lib/Mail/SpamAssassin/HTML.pm michael@374: --- lib/Mail/SpamAssassin/HTML.pm.orig 2010-03-16 15:49:21.000000000 +0100 michael@374: +++ lib/Mail/SpamAssassin/HTML.pm 2011-02-08 16:03:06.000000000 +0100 michael@374: @@ -191,7 +191,7 @@ michael@374: my $self = shift; michael@374: my %options = @_; michael@374: michael@374: - return join('', @{ $self->{text} }) unless keys %options; michael@374: + return join('', @{ $self->{text} }) unless %options; michael@374: michael@374: my $mask; michael@374: while (my ($k, $v) = each %options) { michael@374: Index: lib/Mail/SpamAssassin/Plugin/AntiVirus.pm michael@374: --- lib/Mail/SpamAssassin/Plugin/AntiVirus.pm.orig 2010-03-16 15:49:21.000000000 +0100 michael@374: +++ lib/Mail/SpamAssassin/Plugin/AntiVirus.pm 2011-02-08 16:04:30.000000000 +0100 michael@374: @@ -98,9 +98,9 @@ michael@374: my ($ctype, $boundary, $charset, $name) = michael@374: Mail::SpamAssassin::Util::parse_content_type($p->get_header('content-type')); michael@374: michael@374: - $name = lc $name || ''; michael@374: + $name = lc($name || ''); michael@374: michael@374: - my $cte = lc $p->get_header('content-transfer-encoding') || ''; michael@374: + my $cte = lc($p->get_header('content-transfer-encoding') || ''); michael@374: $ctype = lc $ctype; michael@374: michael@374: if ($name && $name =~ /\.(?:ade|adp|asx|bas|bat|chm|cmd|com|cpl|crt|dll|exe|hlp|hta|inf|ins|isp|js|jse|lnk|mda|mdb|mde|mdt|mdw|mdz|msc|msi|msp|mst|nws|ops|pcd|pif|prf|reg|scf|scr\??|sct|shb|shs|shm|swf|url|vb|vbe|vbs|vbx|vxd|wsc|wsf|wsh)$/) michael@374: Index: lib/Mail/SpamAssassin/Plugin/BodyEval.pm michael@374: --- lib/Mail/SpamAssassin/Plugin/BodyEval.pm.orig 2010-03-16 15:49:21.000000000 +0100 michael@374: +++ lib/Mail/SpamAssassin/Plugin/BodyEval.pm 2011-02-08 16:03:06.000000000 +0100 michael@374: @@ -119,7 +119,7 @@ michael@374: } michael@374: michael@374: # If there are no words, mark if there's at least 1 image ... michael@374: - if (keys %html == 0 && exists $pms->{html}{inside}{img}) { michael@374: + if (!%html && exists $pms->{html}{inside}{img}) { michael@374: # Use "\n" as the mark since it can't ever occur normally michael@374: $html{"\n"}=1; michael@374: } michael@374: Index: lib/Mail/SpamAssassin/Plugin/Check.pm michael@374: --- lib/Mail/SpamAssassin/Plugin/Check.pm.orig 2010-03-16 15:49:21.000000000 +0100 michael@374: +++ lib/Mail/SpamAssassin/Plugin/Check.pm 2011-02-08 16:03:06.000000000 +0100 michael@374: @@ -307,64 +307,51 @@ michael@374: my $package_name = __PACKAGE__; michael@374: my $methodname = $package_name."::_".$ruletype."_tests_".$clean_priority; michael@374: michael@374: - if (defined &{$methodname} && !$doing_user_rules) { michael@374: -run_compiled_method: michael@374: - # dbg("rules: run_generic_tests - calling %s", $methodname); michael@374: - my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline }); michael@374: - my $err = $t->run(sub { michael@374: - no strict "refs"; michael@374: - $methodname->($pms, @{$opts{args}}); michael@374: - }); michael@374: - if ($t->timed_out() && $master_deadline && time > $master_deadline) { michael@374: - info("check: exceeded time limit in $methodname, skipping further tests"); michael@374: - $pms->{deadline_exceeded} = 1; michael@374: - } michael@374: - return; michael@374: - } michael@374: + if (!defined &{$methodname} || $doing_user_rules) { michael@374: michael@374: - # use %nopts for named parameter-passing; it's more friendly to future-proof michael@374: - # subclassing, since new parameters can be added without breaking third-party michael@374: - # subclassed implementations of this plugin. michael@374: - my %nopts = ( michael@374: - ruletype => $ruletype, michael@374: - doing_user_rules => $doing_user_rules, michael@374: - priority => $priority, michael@374: - clean_priority => $clean_priority michael@374: - ); michael@374: - michael@374: - # build up the eval string... michael@374: - $self->{evalstr_methodname} = $methodname; michael@374: - $self->{evalstr_chunk_current_methodname} = undef; michael@374: - $self->{evalstr_chunk_methodnames} = []; michael@374: - $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections michael@374: - $self->{evalstr} = ''; $self->{evalstr_l} = 0; michael@374: - $self->{evalstr2} = ''; michael@374: - $self->begin_evalstr_chunk($pms); michael@374: - michael@374: - $self->push_evalstr_prefix($pms, ' michael@374: - # start_rules_plugin_code '.$ruletype.' '.$priority.' michael@374: - my $scoresptr = $self->{conf}->{scores}; michael@374: - '); michael@374: - if (defined $opts{pre_loop_body}) { michael@374: - $opts{pre_loop_body}->($self, $pms, $conf, %nopts); michael@374: - } michael@374: - $self->add_evalstr($pms, michael@374: - $self->start_rules_plugin_code($ruletype, $priority) ); michael@374: - while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) { michael@374: - $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts); michael@374: - } michael@374: - if (defined $opts{post_loop_body}) { michael@374: - $opts{post_loop_body}->($self, $pms, $conf, %nopts); michael@374: - } michael@374: + # use %nopts for named parameter-passing; it's more friendly michael@374: + # to future-proof subclassing, since new parameters can be added without michael@374: + # breaking third-party subclassed implementations of this plugin. michael@374: + my %nopts = ( michael@374: + ruletype => $ruletype, michael@374: + doing_user_rules => $doing_user_rules, michael@374: + priority => $priority, michael@374: + clean_priority => $clean_priority michael@374: + ); michael@374: + michael@374: + # build up the eval string... michael@374: + $self->{evalstr_methodname} = $methodname; michael@374: + $self->{evalstr_chunk_current_methodname} = undef; michael@374: + $self->{evalstr_chunk_methodnames} = []; michael@374: + $self->{evalstr_chunk_prefix} = []; # stack (array) of source code sections michael@374: + $self->{evalstr} = ''; $self->{evalstr_l} = 0; michael@374: + $self->{evalstr2} = ''; michael@374: + $self->begin_evalstr_chunk($pms); michael@374: + michael@374: + $self->push_evalstr_prefix($pms, ' michael@374: + # start_rules_plugin_code '.$ruletype.' '.$priority.' michael@374: + my $scoresptr = $self->{conf}->{scores}; michael@374: + '); michael@374: + if (defined $opts{pre_loop_body}) { michael@374: + $opts{pre_loop_body}->($self, $pms, $conf, %nopts); michael@374: + } michael@374: + $self->add_evalstr($pms, michael@374: + $self->start_rules_plugin_code($ruletype, $priority) ); michael@374: + while (my($rulename, $test) = each %{$opts{testhash}->{$priority}}) { michael@374: + $opts{loop_body}->($self, $pms, $conf, $rulename, $test, %nopts); michael@374: + } michael@374: + if (defined $opts{post_loop_body}) { michael@374: + $opts{post_loop_body}->($self, $pms, $conf, %nopts); michael@374: + } michael@374: michael@374: - $self->flush_evalstr($pms, 'run_generic_tests'); michael@374: - $self->free_ruleset_source($pms, $ruletype, $priority); michael@374: + $self->flush_evalstr($pms, 'run_generic_tests'); michael@374: + $self->free_ruleset_source($pms, $ruletype, $priority); michael@374: michael@374: - # clear out a previous version of this method michael@374: - undef &{$methodname}; michael@374: + # clear out a previous version of this method michael@374: + undef &{$methodname}; michael@374: michael@374: - # generate the loop that goes through each line... michael@374: - my $evalstr = <<"EOT"; michael@374: + # generate the loop that goes through each line... michael@374: + my $evalstr = <<"EOT"; michael@374: { michael@374: package $package_name; michael@374: michael@374: @@ -373,40 +360,51 @@ michael@374: sub $methodname { michael@374: EOT michael@374: michael@374: - for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) { michael@374: - $evalstr .= " $chunk_methodname(\@_);\n"; michael@374: - } michael@374: + for my $chunk_methodname (@{$self->{evalstr_chunk_methodnames}}) { michael@374: + $evalstr .= " $chunk_methodname(\@_);\n"; michael@374: + } michael@374: michael@374: - $evalstr .= <<"EOT"; michael@374: + $evalstr .= <<"EOT"; michael@374: } michael@374: michael@374: 1; michael@374: } michael@374: EOT michael@374: michael@374: - delete $self->{evalstr}; # free up some RAM before we eval() michael@374: - delete $self->{evalstr2}; michael@374: - delete $self->{evalstr_methodname}; michael@374: - delete $self->{evalstr_chunk_current_methodname}; michael@374: - delete $self->{evalstr_chunk_methodnames}; michael@374: - delete $self->{evalstr_chunk_prefix}; michael@374: - michael@374: - dbg("rules: run_generic_tests - compiling eval code: %s, priority %s", michael@374: - $ruletype, $priority); michael@374: -# dbg("rules: eval code to compile: $evalstr"); michael@374: - my $eval_result; michael@374: - { my $timer = $self->{main}->time_method('compile_gen'); michael@374: - $eval_result = eval($evalstr); michael@374: - } michael@374: - if (!$eval_result) { michael@374: - my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat; michael@374: - warn "rules: failed to compile $ruletype tests, skipping:\n". michael@374: - "\t($eval_stat)\n"; michael@374: - $pms->{rule_errors}++; michael@374: - } michael@374: - else { michael@374: + delete $self->{evalstr}; # free up some RAM before we eval() michael@374: + delete $self->{evalstr2}; michael@374: + delete $self->{evalstr_methodname}; michael@374: + delete $self->{evalstr_chunk_current_methodname}; michael@374: + delete $self->{evalstr_chunk_methodnames}; michael@374: + delete $self->{evalstr_chunk_prefix}; michael@374: + michael@374: + dbg("rules: run_generic_tests - compiling eval code: %s, priority %s", michael@374: + $ruletype, $priority); michael@374: + # dbg("rules: eval code to compile: $evalstr"); michael@374: + my $eval_result; michael@374: + { my $timer = $self->{main}->time_method('compile_gen'); michael@374: + $eval_result = eval($evalstr); michael@374: + } michael@374: + if (!$eval_result) { michael@374: + my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat; michael@374: + warn "rules: failed to compile $ruletype tests, skipping:\n". michael@374: + "\t($eval_stat)\n"; michael@374: + $pms->{rule_errors}++; michael@374: + return; michael@374: + } michael@374: dbg("rules: compiled $ruletype tests"); michael@374: - goto run_compiled_method; michael@374: + } michael@374: + michael@374: +#run_compiled_method: michael@374: +# dbg("rules: run_generic_tests - calling %s", $methodname); michael@374: + my $t = Mail::SpamAssassin::Timeout->new({ deadline => $master_deadline }); michael@374: + my $err = $t->run(sub { michael@374: + no strict "refs"; michael@374: + $methodname->($pms, @{$opts{args}}); michael@374: + }); michael@374: + if ($t->timed_out() && $master_deadline && time > $master_deadline) { michael@374: + info("check: exceeded time limit in $methodname, skipping further tests"); michael@374: + $pms->{deadline_exceeded} = 1; michael@374: } michael@374: } michael@374: michael@374: Index: lib/Mail/SpamAssassin/Plugin/MIMEEval.pm michael@374: --- lib/Mail/SpamAssassin/Plugin/MIMEEval.pm.orig 2010-03-16 15:49:21.000000000 +0100 michael@374: +++ lib/Mail/SpamAssassin/Plugin/MIMEEval.pm 2011-02-08 16:03:32.000000000 +0100 michael@374: @@ -498,7 +498,7 @@ michael@374: # perhaps just limit to test, and image? michael@374: next if ($ctype eq 'application/ics'); michael@374: michael@374: - my $cte = lc $p->get_header('content-transfer-encoding') || ''; michael@374: + my $cte = lc($p->get_header('content-transfer-encoding') || ''); michael@374: next if ($cte !~ /^base64$/); michael@374: foreach my $l ( @{$p->raw()} ) { michael@374: my $len = length $l;