--- Mail-SpamAssassin-3.3.1.ORIG/lib/Mail/SpamAssassin/PerMsgStatus.pm 2011-06-18 14:09:35.000000000 -0500 +++ Mail-SpamAssassin-3.3.1/lib/Mail/SpamAssassin/PerMsgStatus.pm 2011-06-18 14:52:36.000000000 -0500 @@ -892,16 +892,20 @@ # skip the X-Spam- headers, but allow the X-Spam-Prev headers to remain. # since there may be a missing header/body # - my @pristine_headers = split(/^/m, $self->{msg}->get_pristine_header()); + my @pristine_headers; + my $separator = ''; + if ( !$self->{conf}->{headers_only} ) { + @pristine_headers = split(/^/m, $self->{msg}->get_pristine_header()); + for (my $line = 0; $line <= $#pristine_headers; $line++) { next unless ($pristine_headers[$line] =~ /^X-Spam-(?!Prev-)/i); splice @pristine_headers, $line, 1 while ($pristine_headers[$line] =~ /^(?:X-Spam-(?!Prev-)|[ \t])/i); $line--; } - my $separator = ''; if (@pristine_headers && $pristine_headers[$#pristine_headers] =~ /^\s*$/) { $separator = pop @pristine_headers; } + } my $addition = 'headers_ham'; @@ -957,6 +961,7 @@ # through the headers. my $new_hdrs_pre = ''; + my $new_hdrs_post = ''; if (@pristine_headers && $pristine_headers[0] =~ /^Return-Path:/i) { $new_hdrs_pre .= shift(@pristine_headers); while (@pristine_headers && $pristine_headers[0] =~ /^[ \t]/) { @@ -965,6 +970,10 @@ } $new_hdrs_pre .= $self->_get_added_headers($addition); + if ($self->{conf}->{headers_only}) { + return $new_hdrs_pre.$new_hdrs_post; + } + # fix up line endings appropriately my $newmsg = $new_hdrs_pre . join('',@pristine_headers) . $separator; $self->_fixup_report_line_endings(\$newmsg); @@ -972,6 +981,11 @@ return $newmsg.$self->{msg}->get_pristine_body(); } +sub headers_only { + my ($self) = @_; + $self->{conf}->{headers_only} = 1; +} + sub qp_encode_header { my ($self, $text) = @_; --- Mail-SpamAssassin-3.3.1.ORIG/spamc/libspamc.c 2011-06-18 14:09:35.000000000 -0500 +++ Mail-SpamAssassin-3.3.1/spamc/libspamc.c 2011-06-18 14:13:28.000000000 -0500 @@ -1114,6 +1114,8 @@ char *cp, *cpend, *bodystart; int bodylen, outspaceleft, towrite; + if (flags & SPAMC_NOBODY) return EX_OK; + /* at this stage, m->out now contains the rewritten headers. * find and append the raw message's body, up to m->priv->alloced_size * bytes. --- Mail-SpamAssassin-3.3.1.ORIG/spamc/libspamc.h 2011-06-18 14:09:35.000000000 -0500 +++ Mail-SpamAssassin-3.3.1/spamc/libspamc.h 2011-06-18 14:13:28.000000000 -0500 @@ -127,6 +127,7 @@ /* Jan 16, 2007 jm: get markup headers from spamd */ #define SPAMC_HEADERS (1<<15) +#define SPAMC_NOBODY (1<<14) /* December 5, 2007 duncf: send log messages to callback */ #define SPAMC_LOG_TO_CALLBACK (1<<14) --- Mail-SpamAssassin-3.3.1.ORIG/spamd/spamd.raw 2011-06-18 14:09:35.000000000 -0500 +++ Mail-SpamAssassin-3.3.1/spamd/spamd.raw 2011-06-18 14:13:28.000000000 -0500 @@ -1563,14 +1563,13 @@ $status->set_tag('REMOTEHOSTNAME', $remote_hostname); $status->set_tag('REMOTEHOSTADDR', $remote_hostaddr); - # Build the message to send back and measure it - my $msg_resp = $status->rewrite_mail(); - if ($method eq 'HEADERS') { - # just the headers; delete everything after first \015\012\015\012 - $msg_resp =~ s/(\015?\012\015?\012).*$/$1/gs; + $status->headers_only(); } + # Build the message to send back and measure it + my $msg_resp = $status->rewrite_mail(); + my $msg_resp_length = length($msg_resp); if ( $version >= 1.3 ) # Spamc protocol 1.3 means multi hdrs are OK