mime.c:mime_write_tohdr(): complete rewrite (Peter Hofmann)..
commit0add96eaa98829973b89283cd4d4b164903335cc
authorSteffen (Daode) Nurpmeso <sdaoden@users.sf.net>
Fri, 26 Sep 2014 15:05:53 +0000 (26 17:05 +0200)
committerSteffen (Daode) Nurpmeso <sdaoden@users.sf.net>
Sat, 27 Sep 2014 18:50:31 +0000 (27 20:50 +0200)
tree623928a85644533e67026bb22e2a13a60c6ad7a6
parent669a353991a1d700e50a0d6f8f98259ff3d3c3f9
mime.c:mime_write_tohdr(): complete rewrite (Peter Hofmann)..

This function is long known to be very, very sick.
It must be said that the S-nail version was even more broken than
the original Heirloom mailx one, not only because it was possible
to crash it for overlong input.  (On the other hand Heirloom mailx
will generate invalid message headers for such input.)

This new version is still crappy because S-nail doesn't know about
RFC 2231, doesn't honour RFC 2047 completely, because we still
don't make a difference in between structured and unstructed
headers etc., all of that is in the TODO file for almost two years
now, and awaiting the big MIME- and send-layer rewrite that
hopefully addresses all these problems for the better.  A lot more
TODO statements on what is wrong in the function itself.

I first considered to at least address the issue with broken
multibyte sequences by also rewriting all callers and by moving
the iconv(3) into mime_write_tohdr(), where it should belong, so
that we can actually generate self-contained encoded-words instead
of possibly separating multibyte sequences because we are working
on already iconv(3)d data (oh what a crap), but this would require
more testing and overall the standards RFC 2047 and RFC 2231 are
also crap.  Erm.  Well, no, eh, yes, but i cannot do it right now,
it has always been broken and it will take another two years and
then we hopefully have a really correct implementation.  Shit.
Sigh.

I credit Peter Hofmann because it was him who peeked the shitty
MIME handling of S-nail which resulted in [c299c45] (Fix QP
encoding canary violation, 2014-09-22), and was it so strange to
just change the input a bit.
mime.c
mime_cte.c
nail.h
nailfuns.h