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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain
Charset: utf8
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 666
Download (untitled) / with headers
text/plain 666b
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);
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Charset: utf8
Content-Type: text/plain
Message-ID: <rt-3.6.HEAD-29719-1232578393-1923.42627-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 806
Download (untitled) / with headers
text/plain 806b
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);


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.