Issue subject may be broken if the subject field in the receiving email is split into multiple lines
|Target version:||Candidate for next minor release|
When you create issues via email, the subject of the created issue may be broken if the subject field in the original email is split into multiple lines like the following.
Date: Mon, 13 May 2019 13:39:29 +0900 Message-ID: <CALXUZfgwpW-hizEabSAjjkykQGV6-V6bwKu693Cr7cDH6DR7pQ@mail.gmail.com> Subject: =?utf-8?B?zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Cz4PPhM+Fz4bP?= =?utf-8?B?h8+Iz4k=?= From: <firstname.lastname@example.org> To: <email@example.com> Content-Type: text/plain Split bytes subject.
The subject should be decoded like this:
But the subject of the created issue will be the following:
This is due to the bug of mail gem (I tested in 2.7.1).
irb(main):001:0> puts Mail.read('/tmp/split-bytes-subject.eml').subject αβγδεζηθικλμνξοπρςστυφ��ψω => nil
The subject is not split at the boundary between characters but in the middle of bytes that composes a character and mail gem that parses emails does not properly handle such emails. The first line of the decoded subject field is "αβγδεζηθικλμνξοπρςστυφ\xCF" and the second line is "\x87ψω". The character "χ" is consists of two bytes 0xCF and 0x87. These two bytes span two lines. mail gem cannot handle such cases.