Bug 3815 - [review] access relay country in header
Summary: [review] access relay country in header
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Plugins (show other bugs)
Version: 3.0.0
Hardware: Other other
: P5 enhancement
Target Milestone: 3.1.2
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard: can be committed
Keywords:
Depends on:
Blocks: 4236
  Show dependency tree
 
Reported: 2004-09-23 18:38 UTC by Alex Krohn
Modified: 2006-04-05 16:48 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
patch to make the header available in the parsed message patch None Alex Krohn [NoCLA]
redone patch patch None Justin Mason [HasCLA]
fix patch None Justin Mason [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Krohn 2004-09-23 18:38:05 UTC
Attached is a patch to Plugin/RelayCountry.pm that allows you to access the
plugin metadata so you can add a x-spam-relay header showing which countries the
message was sent through using:

add_header all Relay _RELAYCOUNTRY_

in your conf.
Comment 1 Alex Krohn 2004-09-23 18:38:34 UTC
Created attachment 2367 [details]
patch to make the header available in the parsed message
Comment 2 Bob Menschel 2005-07-10 10:34:56 UTC
Triage: Too late IMO to try for 3.1.0, but it looks like a simple enough
enhancement to place into 3.1.1. 
Comment 3 Justin Mason 2005-12-09 05:03:31 UTC
Created attachment 3298 [details]
redone patch

Does this work?

it's a little cleaner, and less likely to be brittle IMO.
Comment 4 Theo Van Dinter 2006-02-22 23:42:55 UTC
justin, do you want this patch to be considered for 3.1.1?
Comment 5 Justin Mason 2006-02-22 23:49:53 UTC
yep, why not
Comment 6 Theo Van Dinter 2006-02-23 00:35:00 UTC
+1
Comment 7 Daryl C. W. O'Shea 2006-02-28 03:21:28 UTC
+1
Comment 8 Theo Van Dinter 2006-02-28 05:15:53 UTC
Sending        lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
Transmitting file data .
Committed revision 381560.
Comment 9 Alex Krohn 2006-03-21 02:32:23 UTC
Hi,

This isn't working for me with 3.1.1. I think the problem is that you are adding
the relay info to the message object:

$msg->{tag_data}{RELAYCOUNTRY} = $countries;

and in sub _get_tag in PerMsgStatus.pm which handles the header parsing:

  elsif ($self->{tag_data}->{$tag}) {
    my $data = $self->{tag_data}->{$tag};
    if (ref $data eq 'CODE') {
      return $data->(@_);
    } else {    
      return $data;
    }
  } 

$self->{tag_data} is from the PerMsgStatus object. I don't see anywhere where
the tag_data from the Message object is copied into the tag_data of PerMsgStatus
object so you end up with a blank header value.

I also couldn't see anything obvious on how to get the PerMsgStatus object from
within extract_data in the plugin.
Comment 10 John Hein 2006-03-22 20:23:30 UTC
The canceled patch from 2004.09.23 works, by the way.
Comment 11 Scott Russell 2006-03-22 20:41:43 UTC
+1, for not working in 3.1.1
Comment 12 Justin Mason 2006-04-03 11:41:01 UTC
Created attachment 3444 [details]
fix

oops.  guess we should have got someone to test it before putting it in 3.1.1
;)

It does indeed appear that the extract_metadata() plugin hook doesn't have the
permsgstatus object available.	Try this one -- it uses the parsed_metadata()
hook again.  it's a lot closer to the first patch (although using the public
apis where possible, as a plugin is supposed to).

this time let's wait for someone to give us a +1 before we put it in 3.1.2 ;)
Comment 13 Alex Krohn 2006-04-03 18:29:50 UTC
+1, latest patch works for me. 
Comment 14 Theo Van Dinter 2006-04-04 04:03:19 UTC
oops.

+1 on 3444
Comment 15 Daryl C. W. O'Shea 2006-04-05 22:17:36 UTC
+1 tested, works.

Don't forget to apply to trunk too.
Comment 16 Justin Mason 2006-04-05 23:48:08 UTC
applied: b310: r391839
trunk: r391838