mail
mail copied to clipboard
Problem folding non-ASCII header
I got something like below with very long Japanese subject.
Subject: =?UTF-8?Q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7=E3=81=99=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=82=88=E3=82=88=E3=82=88?=
I guess !
here is the problem.
Isn't it intended without !
?
https://github.com/mikel/mail/blob/9c466200536ddff7106e6d62022bf7a9658d69b3/lib/mail/fields/unstructured_field.rb#L113
When I removed the !
, I got expected result like below:
Subject: =?UTF-8?Q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7=E3=81=99=E3=81=82=E3=81=82?=
=?UTF-8?Q?=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82?=
=?UTF-8?Q?=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82?=
=?UTF-8?Q?=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82=E3=81=82?=
...
I think the problem here is that the subject should be provided as an original UTF-8 string, not already encoded for transmission as shown.
I gave UTF-8 string.
And got the unfolded header.
In reality this results in garbled text because the resulted line can be longer than 998 byte.
When I remove the !
it works perfectly.
See PR #1570