OneLineBodyRuleType.pm (Mail-SpamAssassin-3.4.3.tar.bz2) | : | OneLineBodyRuleType.pm (Mail-SpamAssassin-3.4.4.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 92 | skipping to change at line 92 | |||
# for {user_rules_of_type}, so that should be fine | # for {user_rules_of_type}, so that should be fine | |||
$self->run_generic_tests ($pms, $priority, | $self->run_generic_tests ($pms, $priority, | |||
consttype => $Mail::SpamAssassin::Conf::TYPE_BODY_TESTS, | consttype => $Mail::SpamAssassin::Conf::TYPE_BODY_TESTS, | |||
type => 'one_line_body', | type => 'one_line_body', | |||
testhash => $pms->{conf}->{one_line_body_tests}, | testhash => $pms->{conf}->{one_line_body_tests}, | |||
args => [ ], | args => [ ], | |||
loop_body => sub | loop_body => sub | |||
{ | { | |||
my ($self, $pms, $conf, $rulename, $pat, %opts) = @_; | my ($self, $pms, $conf, $rulename, $pat, %opts) = @_; | |||
$pat = untaint_var($pat); | my $sub = ' | |||
my $sub; | my ($self, $line) = @_; | |||
my $qrptr = $self->{main}->{conf}->{test_qrs}; | ||||
'; | ||||
if (($conf->{tflags}->{$rulename}||'') =~ /\bmultiple\b/) | if (($conf->{tflags}->{$rulename}||'') =~ /\bmultiple\b/) | |||
{ | { | |||
# support multiple matches | ||||
my ($max) = $conf->{tflags}->{$rulename} =~ /\bmaxhits=(\d+)\b/; | ||||
$max = untaint_var($max); | ||||
if ($max) { | ||||
$sub .= ' | ||||
if (exists $self->{tests_already_hit}->{q{'.$rulename.'}}) { | ||||
return 0 if $self->{tests_already_hit}->{q{'.$rulename.'}} >= '.$max | ||||
.'; | ||||
} | ||||
'; | ||||
} | ||||
# avoid [perl #86784] bug (fixed in 5.13.x), access the arg through ref | # avoid [perl #86784] bug (fixed in 5.13.x), access the arg through ref | |||
$sub = ' | $sub .= ' | |||
my $lref = \$_[1]; | my $lref = \$line; | |||
pos $$lref = 0; | pos $$lref = 0; | |||
'.$self->hash_line_for_rule($pms, $rulename).' | '.$self->hash_line_for_rule($pms, $rulename).' | |||
while ($$lref =~ '.$pat.'g) { | while ($$lref =~ /$qrptr->{q{'.$rulename.'}}/go) { | |||
my $self = $_[0]; | ||||
$self->got_hit(q{'.$rulename.'}, "BODY: ", ruletype => "one_line_body"); | $self->got_hit(q{'.$rulename.'}, "BODY: ", ruletype => "one_line_body"); | |||
'. $self->hit_rule_plugin_code($pms, $rulename, "one_line_body", | '. $self->hit_rule_plugin_code($pms, $rulename, "one_line_body", "") . ' | |||
"return 1") . ' | '. ($max? 'last if $self->{tests_already_hit}->{q{'.$rulename.'}} >= '.$ | |||
max.';' : '') . ' | ||||
} | } | |||
'; | '; | |||
} else { | } else { | |||
$sub = ' | $sub .= ' | |||
'.$self->hash_line_for_rule($pms, $rulename).' | '.$self->hash_line_for_rule($pms, $rulename).' | |||
if ($_[1] =~ '.$pat.') { | if ($line =~ /$qrptr->{q{'.$rulename.'}}/o) { | |||
my $self = $_[0]; | ||||
$self->got_hit(q{'.$rulename.'}, "BODY: ", ruletype => "one_line_body"); | $self->got_hit(q{'.$rulename.'}, "BODY: ", ruletype => "one_line_body"); | |||
'. $self->hit_rule_plugin_code($pms, $rulename, "one_line_body", "return 1") . ' | '. $self->hit_rule_plugin_code($pms, $rulename, "one_line_body", "return 1") . ' | |||
} | } | |||
'; | '; | |||
} | } | |||
return if ($opts{doing_user_rules} && | return if ($opts{doing_user_rules} && | |||
!$self->is_user_rule_sub($rulename.'_one_line_body_test')); | !$self->is_user_rule_sub($rulename.'_one_line_body_test')); | |||
$self->add_temporary_method ($rulename.'_one_line_body_test', '{'.$sub.'}'); | $self->add_temporary_method ($rulename.'_one_line_body_test', $sub); | |||
}, | }, | |||
pre_loop_body => sub | pre_loop_body => sub | |||
{ | { | |||
my ($self, $pms, $conf, %opts) = @_; | my ($self, $pms, $conf, %opts) = @_; | |||
$self->add_evalstr($pms, ' | $self->add_evalstr($pms, ' | |||
my $bodytext = $self->get_decoded_stripped_body_text_array(); | my $bodytext = $self->get_decoded_stripped_body_text_array(); | |||
$self->{main}->call_plugins("run_body_fast_scan", { | $self->{main}->call_plugins("run_body_fast_scan", { | |||
permsgstatus => $self, ruletype => "body", | permsgstatus => $self, ruletype => "body", | |||
priority => '.$opts{priority}.', lines => $bodytext | priority => '.$opts{priority}.', lines => $bodytext | |||
End of changes. 8 change blocks. | ||||
12 lines changed or deleted | 24 lines changed or added |