Skip Menu |
 

This queue is for tickets about the Encode CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: yyang [...] proofpoint.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.39
Fixed in: (no value)



Subject: utf-8 flag is not turned off after calling Encode::encode('UTF-7', $string) to encode an ascii string
Download (untitled) / with headers
text/plain 793b
If you try to encode a pure ASCII string into UTF-7, the UTF-8 flag is not turned off. Test case: use strict; use Test::More tests => 2; use Encode qw(encode); my $foo = "HelloWorld"; utf8::upgrade($foo); ok Encode::is_utf8($foo); my $octets = Encode::encode('UTF-7', $foo, 1); ok !Encode::is_utf8($octets); Proposed fix: --- Unicode/UTF7.pm~ 2010-04-09 14:18:23.000000000 -0700 +++ Unicode/UTF7.pm 2010-04-09 14:13:49.000000000 -0700 @@ -35,7 +35,9 @@ my $bytes = ''; while ( pos($str) < $len ) { if ( $str =~ /\G($re_asis+)/ogc ) { - $bytes .= $1; + my $octets = $1; + utf8::downgrade($octets); + $bytes .= $octets; } elsif ( $str =~ /\G($re_encoded+)/ogsc ) { if ( $1 eq "+" ) {
Download (untitled) / with headers
text/plain 967b
Your patch is in now. Thank you. Dan the Encode Maintainer On Fri Apr 09 17:22:43 2010, yyang wrote: Show quoted text
> If you try to encode a pure ASCII string into UTF-7, the UTF-8 flag is > not turned off. > > Test case: > > use strict; > use Test::More tests => 2; > use Encode qw(encode); > > my $foo = "HelloWorld"; > utf8::upgrade($foo); > > ok Encode::is_utf8($foo); > > my $octets = Encode::encode('UTF-7', $foo, 1); > > ok !Encode::is_utf8($octets); > > > Proposed fix: > > --- Unicode/UTF7.pm~ 2010-04-09 14:18:23.000000000 -0700 > +++ Unicode/UTF7.pm 2010-04-09 14:13:49.000000000 -0700 > @@ -35,7 +35,9 @@ > my $bytes = ''; > while ( pos($str) < $len ) { > if ( $str =~ /\G($re_asis+)/ogc ) { > - $bytes .= $1; > + my $octets = $1; > + utf8::downgrade($octets); > + $bytes .= $octets; > } > elsif ( $str =~ /\G($re_encoded+)/ogsc ) { > if ( $1 eq "+" ) {


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.