Bug 8121 - header rules with keyword all not working
Summary: header rules with keyword all not working
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: 4.0.0
Hardware: All All
: P2 normal
Target Milestone: 4.0.1
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-15 16:15 UTC by Michael Storz
Modified: 2023-03-18 09:05 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Storz 2023-03-15 16:15:53 UTC
rules like __TO_EQ_FROM_1 are not working anymore because the newlines at the end of the line are doubled.

Deleting the \n in line

$hval = scalar(@harr) ? join("\n", @harr) : ' .

of Check.pm corrects the problem.

A workaround for the ALL-rules is to replace the \n with \n{1,2}.
Comment 1 Henrik Krohns 2023-03-15 17:14:46 UTC
Thanks, we are missing many tests for these..

Unfortunately the fix is not that simple. Removing "\n" from Check.pm breaks other stuff like Cc:addr. The real culprit is pms->_get() returning inconsistent line endings, this needs careful vetting and adding tests for all cases.

In the meantime, I've committed the workaround for some tests:

Sending        rules/20_head_tests.cf
Sending        rulesrc/sandbox/jhardin/20_misc_testing.cf
Sending        rulesrc/sandbox/jm/20_basic.cf
Sending        rulesrc/sandbox/khopesh/20_khop_experimental.cf
Sending        rulesrc/sandbox/pds/10_menaces.cf
Transmitting file data .....done
Committing transaction...
Committed revision 1908419.
Comment 2 Henrik Krohns 2023-03-18 09:05:46 UTC
I think it's best that Check.pm checks if get() value has newlines and joins the matching string accordingly. Normally a get() user should know what header/metadata is called and expect certain format, but Check.pm is not normal since it accepts anything from header rules. Will try to document more if I have time.

Sending        lib/Mail/SpamAssassin/PerMsgStatus.pm
Sending        lib/Mail/SpamAssassin/Plugin/Check.pm
Sending        t/header.t
Transmitting file data ...done
Committing transaction...
Committed revision 1908472.