SA Bugzilla – Bug 2856
[review] report_safe_copy_headers should preserve header order correctly for Received
Last modified: 2004-01-08 06:45:13 UTC
Given, report_safe 1 # Copy the Received lines into the containing report header. report_safe_copy_headers Received The received headers of the resulting spam report message look like this; Received: from localhost [127.0.0.1] by screamer with SpamAssassin (2.61 1.212.2.1-2003-12-09-exp); Thu, 18 Dec 2003 22:30:41 -0800 Received: from 61.104.127.124 by lw9fd.law9.hotmail.msn.com with HTTP; Fri, 19 Dec 2003 06:30:17 GMT Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 18 Dec 2003 22:30:17 -0800 Received: from hotmail.com (law9-f123.law9.hotmail.com [64.4.9.123]) by intrepid.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UG1K019722 for <gary@intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 Received: from intrepid.intrepid.com (intrepid.intrepid.com [192.195.190.1]) by screamer.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UGhE008956 for <gary@screamer.intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 In the case of Received heders in particular, the order of appearance has some relevance. They would make more sense if the first line (showing with SpamAssassin) was instead appended to the end of the Received headers that were copied into the message header. The final result would appear as follows: Received: from 61.104.127.124 by lw9fd.law9.hotmail.msn.com with HTTP; Fri, 19 Dec 2003 06:30:17 GMT Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 18 Dec 2003 22:30:17 -0800 Received: from hotmail.com (law9-f123.law9.hotmail.com [64.4.9.123]) by intrepid.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UG1K019722 for <gary@intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 Received: from intrepid.intrepid.com (intrepid.intrepid.com [192.195.190.1]) by screamer.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UGhE008956 for <gary@screamer.intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 Received: from localhost [127.0.0.1] by screamer with SpamAssassin (2.61 1.212.2.1-2003-12-09-exp); Thu, 18 Dec 2003 22:30:41 -0800 In fact, I wonder if this additional SA header is needed at all in the case that that the Received headers were designated to be copied into the header?
Subject: Re: [SAdev] New: safe copy of Received header should append the SA header On Thu, Dec 18, 2003 at 11:55:53PM -0800, bugzilla-daemon@bugzilla.spamassassin.org wrote: > In the case of Received heders in particular, the order of appearance has some > relevance. They would make more sense if the first line (showing with > SpamAssassin) was instead appended to the end of the Received headers that were > copied into the message header. The final result would appear as follows: Except that the most recent Received header needs to be at the top of the list. > In fact, I wonder if this additional SA header is needed at all in the > case that that the Received headers were designated to be copied into > the header? That's a valid question. I would personally say no, but ... I'm open for suggestions from other devs.
Theo replied: > Except that the most recent Received header needs to be at the top of the list. Taking a second look at what's going on -- it looks as if safe_copy_header has *reversed* the order of occurrence of the received headers. The original message headers appear as follows: Received: from intrepid.intrepid.com (intrepid.intrepid.com [192.195.190.1]) by screamer.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UGhE008956 for <gary@screamer.intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 Received: from hotmail.com (law9-f123.law9.hotmail.com [64.4.9.123]) by intrepid.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UG1K019722 for <gary@intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 18 Dec 2003 22:30:17 -0800 Received: from 61.104.127.124 by lw9fd.law9.hotmail.msn.com with HTTP; Fri, 19 Dec 2003 06:30:17 GMT Which are ordered most recent first, as expected. But the copied headers appear as follows: Received: from localhost [127.0.0.1] by screamer with SpamAssassin (2.61 1.212.2.1-2003-12-09-exp); Thu, 18 Dec 2003 22:30:41 -0800 Received: from 61.104.127.124 by lw9fd.law9.hotmail.msn.com with HTTP; Fri, 19 Dec 2003 06:30:17 GMT Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 18 Dec 2003 22:30:17 -0800 Received: from hotmail.com (law9-f123.law9.hotmail.com [64.4.9.123]) by intrepid.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UG1K019722 for <gary@intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 Received: from intrepid.intrepid.com (intrepid.intrepid.com [192.195.190.1]) by screamer.intrepid.com (8.12.8/8.12.8) with ESMTP id hBJ6UGhE008956 for <gary@screamer.intrepid.com>; Thu, 18 Dec 2003 22:30:16 -0800 where all copy headers have been reversed in order of occurrence. Therefore, the header added by SA, which is at the top as it is supposed to be is out of chronological order with the respect to the others. The copying of the SA header remains optional. Perhaps it needs to be there because a new message (the containing report) is being constructed. Thus, it seems the bug summary should be restated that safe_copy_headers should preserve the order of the headers that it is copying.
agreed, this is a bug. >In fact, I wonder if this additional SA header is needed at all in the >case that that the Received headers were designated to be copied into >the header? IMO, it should be kept.
The bug, BTW, is here: foreach ( @hdrtext ) { if ( lc $hdr eq "received" ) { # add Received at the top ... $newmsg = "$hdr: $_$newmsg"; } else { # if not Received, add at the bottom ... $newmsg .= "$hdr: $_"; } } not sure how to go about this without making a "pre" variable which Received will go into specially, then it's added later or something. hrm.
moving to 2.62
taking the ticket.
Created attachment 1629 [details] suggested patch patch fixes the ordering of the copied Received header, also disables the addition of the SpamAssassin Received header if we copied the original one over.
fyi: patch not applied to 2.70 due to cvs freeze
fyi, Justin thought the SA Received header should always be added. imo, if we restore the Received header via config, then we shouldn't add a non-consecutive header. but I'd like to hear other's thoughts before we go yes or no here.
I don't have any strong opinions on this, but can see some merit in adding the SA line so that it is clear that the received trail was tweaked by SA. It is easy enough to ignore. That said, since those received lines are copies of the original, I suppose a case could be made for renaming the copied headers into X-Received-Copy, and then add the SA Received as an actual Received header. Sufficiently complicated? <g>
Subject: Re: [review] report_safe_copy_headers should preserve header order correctly for Received On Fri, Dec 26, 2003 at 05:18:48PM -0800, bugzilla-daemon@bugzilla.spamassassin.org wrote: > That said, since those received lines are copies of the original, I suppose a > case could be made for renaming the copied headers into X-Received-Copy, and > then add the SA Received as an actual Received header. Sufficiently > complicated? <g> Well, that would break the meaning of the config option. Special cases should be avoided if possible.
+1 -- although I would prefer if the SA-generated Received header were to be prepended to the list...
committed to head and 2.62