Subject: | Encode::MIME::Header MIME-Q encoding truncates trailing zeros in some circumstances |
Using the MIME-Q encoding on strings of a certain length containing
trailing zeroes causes the zero to be truncated.
For example:
$x = "\x{c2}\x{a3}xxxxxxxxxxxxxxxxxxx0";
utf8::decode($x);
print encode('MIME-Q', $x);
Prints:
=?UTF-8?Q?=C2=A3xxxxxxxxxxxxxxxxxxx?=
Changing the trailing zero to a 1 will result in:
=?UTF-8?Q?=C2=A3xxxxxxxxxxxxxxxxxxx?==?UTF-8?Q?1?=
Which is, I assume, what should be happening.
This seems to be down to the following line at the end of the _encode
function:
$chunk and push @result, SINGLE->{$enc}($chunk);
I suspect changing it to the following would fix the problem:
length $chunk and push @result, SINGLE->{$enc}($chunk);