Skip Menu |

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 42627
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: dan [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 2.12
  • 2.22
  • 2.26
Fixed in: (no value)



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);
Thanks. Fixed in 2.27 Dan the Encode Maintainer On Wed Jan 21 16:20:43 2009, DAN wrote: Show quoted text
> 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);