Re: [maildropl] Maildrop handling subject containing unicode characters
Brought to you by:
mrsam
|
From: Sam V. <mr...@co...> - 2022-09-07 22:21:16
|
Milan Obuch writes:
> Hi,
>
> recently I found a problem in maildrop when handling subject containing
> unicode characters. Occasionally, I am experiencing mail not being
> delivered to some remote server with error message being (last line)
>
> 553 Unable to deliver Unicode E-mail to a non-Unicode mail server.
>
> After some investigation I found it comes from my maildrop script doing
> some kind of mailing list, and now I have a simple test case.
>
> I added to my maildrop script (another mailbox, so I can test things
> without disturbing my application) following:
>
> if (/^Subject: *(Test .*)/)
> {Subject=$MATCH1
> echo "subject $MATCH1"
> xfilter 'reformail -i"Subject: $Subject"'
> }
>
> This should just check for subject starting with Test to invoke some
> action, replacing the subject with new subject, constructed, but for
> this example it should be the same.
You can write
/^Subject:.*(<some unicode character>)/
and it'll match the subject line whether its unicode characters were
encoded, in UTF-8 or any other encoding.
Your maildrop script can expect to see only Unicode content, and should use
UTF-8.
> It is now understandable that mail with subject mangled this way could
> be rejected by some external mail server. Mostly it works, but this is
> just kind of happy accident, given the spec.
>
> My question is, how should this be handled correctly. If I understand
> what happens, $MATCH variable contains matched text in internal Unicode
> binary encoding, and it should be encoded back using either base64 or
> quoted printable character encoding, if some non ASCII characters are
> in string given.
>
> Any hints appreciated...
You can use reformime to reencode unicode back into ascii-only:
$ reformime -o 'Hóla!'
=?UTF-8?B?SMOzbGEh?=
So, you probably want something like:
Subject=`reformime -o "$MATCH1"`
and, with everything else, it should work.
maildrop does not do variable substitution inside backticks, so this command
gets passed directly for execution to the shell, and it safely substitutes
$MATCH1, from the inherited environment.
Note that, either way, changing the subject line will likely break any
signatures that include the original subject line.
|