FixSubstringBoundaries errors

Radoslav Bodó bodik at
Wed Dec 5 15:49:18 UTC 2018


after the latest upgrade of our server from MailScanner 4 to 5.1.2 we
have identified that FixSubstringBoundaries is not working properly.


* the function FixSubstringBoundaries(...) updates the body and headers
in the processed $message structure, but final delivered message
contains original non-updated Conten-Type boundary header

* that renders updated messages unusable on the server/client side. In
some cases the messages are just not properly displayed (roundcube), in
some other cases might be deleted silently on the background by the
client (thunderbird).

* possibly corrupted messages can be identified from the logs by
'Content Checks: Fixed awkward MIME boundary for Cyrus IMAP server'

System affected:

	debian 9.5 stretch
	postfix 3.1.8-0+deb9u1
	mailscanner 5.1.2-2
	perl 5.24.1-3+deb9u4
	libmime-tools-perl 5.508-1

The attachments of this message contains data for reproducing the issue:

* mailboundary1.txt            .. test message to reproduce
* mailboundary1-corrupted.txt  .. resulting message documenting the fail
* 		       .. testing helper

cat /tmp/mailboundary1.txt | /tmp/ --sender
s at webmail-test.redacted --to s at webmail-test.redacted --raw

The only workaround I've been able to come up is to disable the feature
in the code by commenting out

for the time being.

I've tried to track down message processing down to

but since my knowledge of mailscanner and postfix internals are poor
I've got lost in DeliverModifiedBody(...)

Any help or idea would be highly appreciated.

Thank you
-------------- next part --------------
From: bodik at
To: bodik at
Subject: boundaryfix
Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable

Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable

Content-Type: image/gif; NAME="logo.gif"
Content-Transfer-Encoding: BASE64
Content-Description: logo.gif
Content-ID: <logo.gif>

-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-python
Size: 2185 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the MailScanner mailing list