mscdex/node-imap — pull request #351 by chotiwat (2014-02-27 18:34:30+00:00)
Title: Parser: ignore linear whitespace between consecutive mime-encoded words in header

Hi. This pull request should fix a bug which sometimes adds extra whitespace to the resulting header values. For example, the header line ``Subject: ไทย ไทย ไทย`` could be encoded by some client as
```
Subject: =?UTF-8?Q?=E0=B9=84=E0=B8=97=E0=B8=A2_=E0=B9=84?=
=?UTF-8?Q?=E0=B8=97=E0=B8=A2_=E0=B9=84=E0=B8=97?= =?UTF-8?Q?=E0=B8=A2?=
```
which will be decoded as `` Subject: ไทย ไทย ไท ย``. The added whitespace in the result before the last character comes from the whitespace between two encoded words in the second line.

If I'm not mistaken, we should ignore any whitespace between encoded words when parsing header values according to the following RFC section (http://tools.ietf.org/html/rfc2047#section-5):
```
Ordinary ASCII text and 'encoded-word's may appear together in the
same header field. However, an 'encoded-word' that appears in a
header field defined as '*text' MUST be separated from any adjacent
'encoded-word' or 'text' by 'linear-white-space'.
```

Thanks.