nicm / fdm

fdm source code
268 stars 50 forks source link

Adding a header after rewrite unfolds other headers (under some unknown circumstances) #63

Open kusalananda opened 5 years ago

kusalananda commented 5 years ago

Using an action that rewrites the message, and then adds a header, as in

action "bogofilter" {
    remove-header "X-Bogosity"
    rewrite "/usr/local/bin/bogofilter -e -p -u"
    add-header "X-Filtered-Date" value "%[rfc822date]"
}

seems to sometimes unfold the headers in the message that is later saved to a mailbox. By "unfolding" I mean removes newlines, making each header line span only a single line.

Removing the add-header action from the above composite action resolves this and leaves the headers untouched.

I'm not entirely under what circumstances the headers are unfolded (I haven't been able to write a set of actions+rules to actually provoke this behaviour), but in all cases when this does occur, it happens consistently and removing the addition of a new header to the message seems to resolve it.

I'm using fdm 1.9 as packaged with OpenBSD-current, but this was also seen with fdm compiled from the master branch.

kusalananda commented 5 years ago

I managed to reproduce the issue:

Return-Path: <kk@eeyore.my.domain>
Delivered-To: kk@eeyore.my.domain
Received: from localhost (eeyore.my.domain [local])     by eeyore.my.domain (OpenSMTPD) with ESMTPA id 5a92e69b
        for <kk@eeyore.my.domain>;      Thu, 18 Apr 2019 09:47:58 +0200 (CEST)
From: Kusalananda <kk@eeyore.my.domain>
Date: Thu, 18 Apr 2019 09:47:58 +0200 (CEST)
To: kk@eeyore.my.domain
Subject: test
Message-ID: <8a17f1a0f279c2e3@eeyore.my.domain>
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4
X-Filtered-Date: Thu, 18 Apr 2019 09:48:03 +0200

test

This was produced by the same action as in the previous comment, but the remove-header was replaced by

remove-headers { "X-Bogosity" "X-Filtered-Date" }