You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2009/08/25 21:11:36 UTC
svn commit: r807765 -
/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Author: mmartinec
Date: Tue Aug 25 19:11:35 2009
New Revision: 807765
URL: http://svn.apache.org/viewvc?rev=807765&view=rev
Log:
(related to Bug 6185): factor out common code as _get_added_headers;
add new tags ADDEDHEADERHAM and ADDEDHEADERSPAM, making added header
fields available to the caller
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=807765&r1=807764&r2=807765&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Tue Aug 25 19:11:35 2009
@@ -651,6 +651,20 @@
}
}
+sub _get_added_headers($) {
+ my ($self, $which) = @_;
+ my $str = '';
+ # use string appends to put this back together -- I finally benchmarked it.
+ # join() is 56% of the speed of just using string appends. ;)
+ foreach my $hf_ref (@{$self->{conf}->{$which}}) {
+ my($hfname, $hfbody) = @$hf_ref;
+ my $line = $self->_process_header($hfname,$hfbody);
+ $line = $self->qp_encode_header($line);
+ $str .= "X-Spam-$hfname: $line\n";
+ }
+ return $str;
+};
+
# rewrite the message in report_safe mode
# should not be called directly, use rewrite_mail instead
#
@@ -721,13 +735,7 @@
$newmsg .= "Subject: $subject" if defined $subject;
$newmsg .= "Date: $date" if defined $date;
$newmsg .= "Message-Id: $msgid" if defined $msgid;
-
- foreach my $hf_ref (@{$self->{conf}->{headers_spam}}) {
- my ($hfname, $hfbody) = @$hf_ref;
- my $line = $self->_process_header($hfname,$hfbody);
- $line = $self->qp_encode_header($line);
- $newmsg .= "X-Spam-$hfname: $line\n" # add even if empty
- }
+ $newmsg .= $self->_get_added_headers('headers_spam');
if (defined $self->{conf}->{report_safe_copy_headers}) {
my %already_added = map { $_ => 1 } qw/from to cc subject date message-id/;
@@ -905,15 +913,7 @@
$new_hdrs_post .= $hdr;
}
}
-
- # use string appends to put this back together -- I finally benchmarked it.
- # join() is 56% of the speed of just using string appends. ;)
- foreach my $hf_ref (@{$self->{conf}->{$addition}}) {
- my ($hfname, $hfbody) = @$hf_ref;
- my $line = $self->_process_header($hfname,$hfbody);
- $line = $self->qp_encode_header($line);
- $new_hdrs_pre .= "X-Spam-$hfname: $line\n";
- }
+ $new_hdrs_pre .= $self->_get_added_headers($addition);
# fix up line endings appropriately
my $newmsg = $new_hdrs_pre.$new_hdrs_post.$separator;
@@ -1222,6 +1222,14 @@
return $self->{main}->timer_report();
},
+ ADDEDHEADERHAM => sub {
+ return $self->_get_added_headers('headers_ham');
+ },
+
+ ADDEDHEADERSPAM => sub {
+ return $self->_get_added_headers('headers_spam');
+ },
+
);
my $data = "";