[dev] MIME Encoding and RFC 2231

Michael M Slusarz slusarz at bigworm.colorado.edu
Thu Apr 29 16:19:32 PDT 2004


http://www.faqs.org/rfcs/rfc2231.html

YUCK.  Where the heck has this RFC been.  Turns out we have been encoding stuff
wrongly forever, namely as follows (RFC 2047 [5]):

   + 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'.

This includes the Content-Disposition parameter "filename" and the various
Content-Type parameters, including "filename" and "name".

What makes this worse is that it appears that some IMAP servers (most?) do not
handle this encoding very well.  I am using a version of Courier IMAP that is
only a few months old, and it does not support this encoding.  Instead a RFC
2231 encoded parameter is returned from imap_fetchstructure() as follows:

[parameters] => Array
(
    [0] => stdClass Object
    (
        [attribute] => name*0
        [value] => us-ascii'en'This%20is%20even%20more%20name*1=fun
    )

)

Correct behavior would result in a return structure like this:
[parameters] => Array
(
    [0] => stdClass Object
    (
        [attribute] => name
        [value] => This is even more fun
    )

)

This is because the IMAP server is *supposed* to do the conversions
automatically.  According to draft-ietf-imapext-i18n-01.txt:

   o  MIME Parameter Value and Encoded Word Extensions [11] for
      filenames.  Quality IMAP server implementations will automatically
      combine multipart parameters when generating the BODYSTRUCTURE.
      There is also some deployed non-standard use of MIME header
      encoding inside double-quotes for filenames.

But obviously, this not the current situation.

So the issue is do we implement the "correct" RFC encoding or stick with our
current method.  Although the current method technically isn't correct, we have
never seemed to run into problems before.  Plus, if we start sending RFC 2231
encoded messages, odds are that 99.9% of people receiving these messages will
not be able to handle them.  And, add to this that I have not ONCE, in the last
2+ years, seen this kind of encoding.  And I have been working on the MIME
stuff pretty much that whole time.

Comments/suggestions would be great.

michael

______________________________________________
Michael Slusarz [slusarz at bigworm.colorado.edu]
The University of Colorado at Boulder


More information about the dev mailing list