Fix for an Issue in mailhandler/spameater - sub sendMail

Discussion re sg development. You don't have to be a developer.

Fix for an Issue in mailhandler/spameater - sub sendMail

Postby rkbbssg » Sun Oct 28, 2018 4:07 pm

Hello,

I wrote to Josh about this a few days ago, but apparently my email did not get through.

There is an issue in the sendMail sub in file mailhandler/spameater -

When it adds the SpamGourmet information to a Subject header, if the header spans multiple lines, then the information is
appended to the first line, when it should be the last.

Example - portion of headers from an email I got through SpamGourmet (note the 2-line subject header):

Code: Select all
Date: Sun, 28 Oct 2018 17:53:49 +0200
Subject: This is a Long Header, to show the Issue, (tmp: message 17 of 20)
 Note it's actually not that long, but you can still see the problem.
X-Remote-Spamgourmet: (tmp: message 17 of 20)


You can see the information (tmp: message 17 of 20) is in the middle of the Subject header. That's because the header
originally spans 2 lines. According to RFC 2822 (section 2.2.3. Long Header Fields) - a header can indeed span more than 1 line,
as long as the next lines (after the 1st) start with whitespace.

It should have been forwarded like this:

Code: Select all
Date: Sun, 28 Oct 2018 17:53:49 +0200
Subject: This is a Long Header, to show the Issue,
 Note it's actually not that long, but you can still see the problem. (tmp: message 17 of 20)
X-Remote-Spamgourmet: (tmp: message 17 of 20)


The fix for this issue is a small change in the regex used in line 808 at sub sendMail in the file mailhandler/spameater:

Simply, replace this line:

Code: Select all
 my $check = $$msgref =~ s/(^Subject\:.*$)/$1$subjecttext/mi;


With this one:

Code: Select all
 my $check = $$msgref =~ s/(^Subject\:(.|(\n\s))*$)/$1$subjecttext/mi;


Could someone please, please, implement this fix in the spamgourmet site?

Many thanks :)

Ron
rkbbssg
 
Posts: 5
Joined: Sun Oct 28, 2018 3:44 pm

Re: Fix for an Issue in mailhandler/spameater - sub sendMail

Postby josh » Fri Nov 23, 2018 10:54 pm

nice!

That's a really old bug that nobody ever complained about, but it did sort of drive me nuts.

Thanks!

Josh
josh
 
Posts: 1371
Joined: Fri Aug 29, 2003 2:28 pm

Re: Fix for an Issue in mailhandler/spameater - sub sendMail

Postby rkbbssg » Sun Nov 25, 2018 6:41 am

Glad to help Josh, all the best to you, and many thanks.
rkbbssg
 
Posts: 5
Joined: Sun Oct 28, 2018 3:44 pm


Return to Developers

Who is online

Users browsing this forum: No registered users and 21 guests

cron