You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Olivier Coutu <ol...@zerospam.ca> on 2016/12/06 16:19:01 UTC

PerMsgStatus get('From') returns different values in the same email

I have a plugin that has the following lines:

my $header_from = $pms->get('From', 0);
dbg("ZS_HeadersCompare: $functname($rulename): header_from = $header_from")

I am looking to get the entire "From" field, which should be pretty 
straightforward. I am running this on an email with the following "from":

From: "jerome.o.simard@gmail.com" <je...@gmail.com>

When I run it on machine A (Ubuntu 12.04, SpamAssassin version 3.4.1, 
Perl version 5.14.2), the outcome is as expected:

ocoutu@hostA:~$ spamassassin -D 2>&1 < bug.eml | grep "header_from ="
d�c  6 09:47:25.873 [25961] dbg: ZS_HeadersCompare: get_header_from(__Z_SAME_FROM_TRIM_DOM): header_from = "jerome.o.simard@gmail.com" <je...@gmail.com>
d�c  6 09:47:25.883 [25961] dbg: ZS_HeadersCompare: get_header_from(__Z_SAME_FROM_SLD): header_from = "jerome.o.simard@gmail.com" <je...@gmail.com>
d�c  6 09:47:25.884 [25961] dbg: ZS_HeadersCompare: get_header_from(__Z_REPLY_TO_IS_FROM_TRIM_DOM): header_from = "jerome.o.simard@gmail.com" <je...@gmail.com>
[...]

However, if I run that on machine B (Ubuntu 16.04, SpamAssassin version 
3.4.1, Perl version 5.22.1) that I have recently created, after the 
first call to the /get//('From', 0)/ which returns the correct value, 
the following calls return the values with an added underscore between 
the from_name and the from_address:

ocoutu@hostB:~$ spamassassin -D 2>&1 < bug.eml | grep "header_from ="
d�c  6 09:45:28.331 [13600] dbg: ZS_HeadersCompare: get_header_from(__Z_SAME_FROM_TRIM_DOM): header_from = "jerome.o.simard@gmail.com" <je...@gmail.com>
d�c  6 09:45:28.332 [13600] dbg: ZS_HeadersCompare: get_header_from(__Z_SAME_FROM_SLD): header_from = "jerome.o.simard@gmail.com"_<je...@gmail.com>
d�c  6 09:45:28.334 [13600] dbg: ZS_HeadersCompare: get_header_from(__Z_REPLY_TO_IS_FROM_TRIM_DOM): header_from = "jerome.o.simard@gmail.com"_<je...@gmail.com>
[...]

This can also be illustrated with the /__FROM_RUNION/ rule, which I have 
not modified in any way:

d�c  6 10:59:36.149 [24034] dbg: rules: ran header rule __FROM_RUNON ======> got hit: ""jerome.o.simard@gmail.com"_<jerome"

Since this rule is called by the built-in config files with /From =~ 
/\S+<\w+//, it appears like the problem is not just with the way I am 
calling it.

I have a similar piece of code that uses /$pms->get('To', 0)/ and has 
the same issue.

The bug appears whether the domain is a freemailer or not, but does not 
happen when there is no from_name.

I am looking for tips as to where the problem might be. Is it possible 
that my /get/ or other calls are modifying the PerMsgStatus? Could it be 
related to patches that have been applied with the Ubuntu install?

-- 
Olivier Coutu
noc@zerospam.ca


Re: PerMsgStatus get('From') returns different values in the same email

Posted by Olivier Coutu <ol...@zerospam.ca>.
On 2016-12-06 11:19, Olivier Coutu wrote:
> However, if I run that on machine B (Ubuntu 16.04, SpamAssassin 
> version 3.4.1, Perl version 5.22.1) that I have recently created, 
> after the first call to the /get//('From', 0)/ which returns the 
> correct value, the following calls return the values with an added 
> underscore between the from_name and the from_address:
> ocoutu@hostB:~$ spamassassin -D 2>&1 < bug.eml | grep "header_from ="
> d�c  6 09:45:28.331 [13600] dbg: ZS_HeadersCompare: get_header_from(__Z_SAME_FROM_TRIM_DOM): header_from ="jerome.o.simard@gmail.com"  <je...@gmail.com>
> d�c  6 09:45:28.332 [13600] dbg: ZS_HeadersCompare: get_header_from(__Z_SAME_FROM_SLD): header_from ="jerome.o.simard@gmail.com"_<je...@gmail.com>
> d�c  6 09:45:28.334 [13600] dbg: ZS_HeadersCompare: get_header_from(__Z_REPLY_TO_IS_FROM_TRIM_DOM): header_from ="jerome.o.simard@gmail.com"_<je...@gmail.com>
> [...]
After some investigation, the perl version appears to be the issue.

The latest version of perl that I found that does not create this issue 
is perl-5.18.4 and all versions from perl-5.20.3 to perl-5.25.7 create 
the issue.

Has anyone else encountered this problem with the recent perl versions?
> This can also be illustrated with the /__FROM_RUNION/ rule, which I 
> have not modified in any way:
> d�c  6 10:59:36.149 [24034] dbg: rules: ran header rule __FROM_RUNON ======> got hit: ""jerome.o.simard@gmail.com"_<jerome"
> Since this rule is called by the built-in config files with /From =~ 
> /\S+<\w+//, it appears like the problem is not just with the way I am 
> calling it.
If I disable my plugin completely the problem goes away and __FROM_RUNON 
works as expected again.

I realize that using /From:addr/ instead of /From/ would work but the 
documentation indicates that only the first address is kept, which works 
most of the time for /From/ but gives very different results for /To/ 
when there are multiple recipients. Any workaround would be appreciated.