Vagabond/gen_smtp — pull request #58 by seriyps (2013-12-29 20:34:35+00:00)
Title: Permissive quoted-printable headers parser

This patch was little discussed in #36 eg https://github.com/Vagabond/gen_smtp/issues/36#issuecomment-29348245
So, this is a well-formed patch.

The main idea is that many MIME encoders do improper quoted-printable headers folding for multibyte charsets, so they split string by bytes, not by UTF-8 characters, so if we try to decode folded header line-by-line we get error like `{error,einval}`.

So, for header
```
Subject: =?utf-8?B?Tk9EMzIgU21hcnQgU2VjdXJpdHkgLSDQsdC10YHQv9C70LDR?=
=?utf-8?B?gtC90LDRjyDQu9C40YbQtdC90LfQuNGP?=
```
```
> eiconv:convert("utf-8", "utf-8", base64:decode(<<"Tk9EMzIgU21hcnQgU2VjdXJpdHkgLSDQsdC10YHQv9C70LDR">>)).
{error,einval}
```
But if we join 2 lines in one, header decodes successfully
```
> eiconv:convert("utf-8", "utf-8", base64:decode(<<"Tk9EMzIgU21hcnQgU2VjdXJpdHkgLSDQsdC10YHQv9C70LDR", "gtC90LDRjyDQu9C40YbQtdC90LfQuNGP">>)).
{ok,<<78,79,68,51,50,32,83,109,97,114,116,32,83,101,99,
117,114,105,116,121,32,45,32,208,177,208,181,...>>}
```