Problems with header checks

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with header checks

Stephan Seitz-2
Hi!

I’m using Debian 10 with postfix 3.4.5.

Trying to solve the problem with non-Re subjects I have found a regex for
header checks.

So I have a „/etc/postfix/header_check.pcre” with:
/eSubject:\s*((RE|AW|Aw|Antw|Antwort|RES|SV):\s*)+(.*)$/ REPLACE Subject: Re: $3

In main.cf:
header_checks = pcre:/etc/postfix/header_check.pcre

Now I have noticed that this isn’t always working. Postfix logs if the
rule is getting used. I have a friend who is using the GMX webinterface
which is using AW: instead of Re:.
I can see in the mail logs that sometimes the AW gets replaced with Re
and sometimes it stays.
The mail logs are in both cases the same
(client=mout.gmx.net[212.227.15.15]), besides the fact that if it works
I have an additional log line (replace: header Subject:…).

Has anyone an idea how I can debug this further? Or why it is only
sometimes working?

Shade and sweet water!

        Stephan

--
|    If your life was a horse, you'd have to shoot it.    |
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Stephan Seitz-2
On Fr, Nov 08, 2019 at 01:44:53 +0100, Stephan Seitz wrote:
>Has anyone an idea how I can debug this further? Or why it is only
>sometimes working?

I think I’ve found the problem. It happens if the subject has non-ASCII
characters to the line looks like:

=?UTF-8?Q?Aw=3A_Weinprobe_gut_=C3=BCberstanden=3F?=

Has anyone an idea how can I change the regex so that it works with
encoded subject lines? Or can I tell postfix to decode the line, then
employ the regex und encode the line again?

Shade and sweet water!

        Stephan

--
|    If your life was a horse, you'd have to shoot it.    |
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Christian Kivalo


On November 8, 2019 1:53:13 PM GMT+01:00, Stephan Seitz <[hidden email]> wrote:

>On Fr, Nov 08, 2019 at 01:44:53 +0100, Stephan Seitz wrote:
>>Has anyone an idea how I can debug this further? Or why it is only
>>sometimes working?
>
>I think I’ve found the problem. It happens if the subject has non-ASCII
>
>characters to the line looks like:
>
>=?UTF-8?Q?Aw=3A_Weinprobe_gut_=C3=BCberstanden=3F?=
>
>Has anyone an idea how can I change the regex so that it works with
>encoded subject lines? Or can I tell postfix to decode the line, then
>employ the regex und encode the line again?
For such encoded content you need to match the encoded form. See http://www.postfix.org/BUILTIN_FILTER_README.html
I don't think that postfix is the right tool for this job, on the other hand I don't really see the problem you're trying to solve.
Be careful not to break dkim signatures when modifying headers. Subject is a signed header in most cases.
>Shade and sweet water!
>
> Stephan

--
Christian Kivalo
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Jaroslaw Rafa
Dnia  8.11.2019 o godz. 14:27:18 Christian Kivalo pisze:
>
> I don't think that postfix is the right tool for this job, on the other
> hand I don't really see the problem you're trying to solve.

If I understand the OP correctly, he is trying to solve the problem of
e-mail clients using other prefixes instead of "Re:" for replies (for
example "AW:" or "Odp:" - these are among a few I encountered myself). When
you exchange emails back and forth, this usually leads to chain of prefixes
like "Re: Odp: Re: Odp: ..." at the beginning of the subject line. He is
trying to replace all these strings by a proper "Re:".
--
Regards,
   Jaroslaw Rafa
   [hidden email]
--
"In a million years, when kids go to school, they're gonna know: once there
was a Hushpuppy, and she lived with her daddy in the Bathtub."
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Stephan Seitz-2
On Fr, Nov 08, 2019 at 03:11:34 +0100, Jaroslaw Rafa wrote:
>If I understand the OP correctly, he is trying to solve the problem of
>e-mail clients using other prefixes instead of "Re:" for replies (for
>example "AW:" or "Odp:" - these are among a few I encountered myself). When
>you exchange emails back and forth, this usually leads to chain of prefixes
>like "Re: Odp: Re: Odp: ..." at the beginning of the subject line. He is
>trying to replace all these strings by a proper "Re:".

Exactly that’s my problem. Sorry, if I wasn’t clear enough.

But the warning about breaking DKIM signatures if I change the subject
line is of course a valid one.

Shade and sweet water!

        Stephan

--
|    If your life was a horse, you'd have to shoot it.    |
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Jaroslaw Rafa
Dnia  8.11.2019 o godz. 15:23:52 Stephan Seitz pisze:
>
> But the warning about breaking DKIM signatures if I change the
> subject line is of course a valid one.

If you do it on incoming mail only, and after DKIM signature has already
been verified, then I think there's no problem. Am I right?

But in that case probably LDA is the best place to do such change. Some time
ago I was doing something similar via procmail.
--
Regards,
   Jaroslaw Rafa
   [hidden email]
--
"In a million years, when kids go to school, they're gonna know: once there
was a Hushpuppy, and she lived with her daddy in the Bathtub."
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Robert L Mathews
On 11/8/19 6:31 AM, Jaroslaw Rafa wrote:

> If you do it on incoming mail only, and after DKIM signature has already
> been verified, then I think there's no problem. Am I right?

Not always, because some people use tools that verify the signature
later on, such as this one:

 https://github.com/lieser/dkim_verifier

--
Robert L Mathews
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Stephan Seitz-2
In reply to this post by Jaroslaw Rafa
On Fr, Nov 08, 2019 at 03:31:05 +0100, Jaroslaw Rafa wrote:
>But in that case probably LDA is the best place to do such change. Some
>time ago I was doing something similar via procmail.

Yes, I could do the same with procmail. But procmail will probably like
postfix use the encoded subject, so I don’t know how to handle subjects
like =?UTF-8?Q?Aw=3A_Weinprobe_gut_=C3=BCberstanden=3F?=

Shade and sweet water!

        Stephan

--
|    If your life was a horse, you'd have to shoot it.    |
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Wietse Venema
Stephan Seitz:
> On Fr, Nov 08, 2019 at 03:31:05 +0100, Jaroslaw Rafa wrote:
> >But in that case probably LDA is the best place to do such change. Some
> >time ago I was doing something similar via procmail.
>
> Yes, I could do the same with procmail. But procmail will probably like
> postfix use the encoded subject, so I don?t know how to handle subjects
> like =?UTF-8?Q?Aw=3A_Weinprobe_gut_=C3=BCberstanden=3F?=

In the header_checks file:

/^(Subject:\s*=\?UTF-8\?Q\?)Aw([:=].+)/ REPLACE ${1}Re${2}

Or use some pattern that also captures strings other than UTF-8?Q.
I am lazy.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Problems with header checks

Stephan Seitz-2
In reply to this post by Jaroslaw Rafa
On Fr, Nov 08, 2019 at 03:31:05 +0100, Jaroslaw Rafa wrote:
>But in that case probably LDA is the best place to do such change. Some
>time ago I was doing something similar via procmail.

I found a great program for procmail:
https://fex.belwue.de/fstools/#aw2re

It fixes the subject and can remove ML information from the subject as
well.

Shade and sweet water!

        Stephan

--
|    If your life was a horse, you'd have to shoot it.    |