[Dovecot] Dovecot failing to parse some UTF-8 encoded attachment filenames, returning empty string instead

Andrew Richards ar-dovecotlist at acrconsulting.co.uk
Thu Sep 22 14:31:40 EEST 2011


On Thursday 22 September 2011 00:45:32 Timo Sirainen wrote:
> On 22.9.2011, at 1.59, Andrew Richards wrote:
> > I'm seeing a strange problem with some attachment filenames that are
> > UTF-8 encoded. The problem seems to be related to spaces and/or
> > unusual characters in filenames, like accented characters (or perhaps
> > just to filenames if UTF-8 encoded; I've not explored that fully).
> 
> The problem is that the client sends it wrong:
> > Content-Type: application/octet-stream;
> > 	name==?UTF-8?B?dGhpc19mYWlscy50eHQ=?=
> > Content-Disposition: attachment;
> > 	filename==?UTF-8?B?dGhpc19mYWlscy50eHQ=?=
> 
> These are both wrong. First of all they are illegal because they have = and 
? characters, from RFC 2045:
> ...snip...
> Also from RFC 2047 (encoded-word is the =?UTF-8?...?= thing):
> >    + An 'encoded-word' MUST NOT be used in parameter of a MIME
> >      Content-Type or Content-Disposition field, or in any structured
> >      field body except within a 'comment' or 'phrase'.
> ...snip...
> Anyway .. I'll check tomorrow if I can easily add code to workaround your
>  problem. If it's just a minor change I'll do it.

Wow - a very thorough response only 45 minutes after I'd posted the question, 
and in your follow up message you've already provided a suggested fix - a huge 
thank you!

So in summary it's a "Garbage in -> Garbage out" issue... This also explains 
why I'm only getting this issue with one client after a Courier->Dovecot 
migration. I'll research which mail client program(s) are generating the 
faulty messages for completeness for this thread.

I expect to test the fix later today or tomorrow, I'll update the thread 
accordingly when I've done so.

Best regards,

Andrew.



More information about the dovecot mailing list