develooper Front page | perl.perl5.porters | Postings from April 2012

[perl #112532] eval( Dumper( 'Latin1' ) ) can result in malformed UTF8

Thread Previous | Thread Next
From:
Zbigniew Łukasiak
Date:
April 21, 2012 10:49
Subject:
[perl #112532] eval( Dumper( 'Latin1' ) ) can result in malformed UTF8
Message ID:
rt-3.6.HEAD-4610-1334816705-1074.112532-75-0@perl.org
# New Ticket Created by  Zbigniew Łukasiak 
# Please include the string:  [perl #112532]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=112532 >


This is a bug report for perl from zzbbyy@gmail.com,
generated with the help of perlbug 1.39 running under perl 5.15.9.


-----------------------------------------------------------------
Dumper( "\x{f3}" ) returns a string encoded in Latin1.  This results
in malformed UTF8 when it is fed back to eval and 'use utf8' is in force.
This is illustrated by the following test case:

use strict;
use warnings;

use utf8;

use Devel::Peek;
use Test::More;
use Data::Dumper;
$Data::Dumper::Terse = 1;


my $last = eval( Dumper( "\x{f3}" ) );
is( $last, "\x{f3}", 'eval' );
Dump( $last );

done_testing;

__OUTPUT__

not ok 1 - eval
#   Failed test 'eval'
#   at d.pl line 13.
Wide character in print at
/home/zby/localperl/lib/5.15.9/Test/Builder.pm line 1759.
#          got: 'ó'
#     expected: 'ó'
SV = PV(0x21a4060) at 0x1ed1e40
 REFCNT = 1
 FLAGS = (PADMY,POK,pPOK,UTF8)
 PV = 0x2064050 "\363"\0Malformed UTF-8 character (1 byte, need 4,
after start byte 0xf3) in subroutine entry at d.pl line 14.
[UTF8 "\x{0}"]
 CUR = 1
 LEN = 16
1..1
# Looks like you failed 1 test of 1.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
   category=library
   severity=medium
   module=Data::Dumper
---
Site configuration information for perl 5.15.9:

Configured by zby at Wed Apr 18 21:43:42 CEST 2012.

Summary of my perl5 (revision 5 version 15 subversion 9) configuration:

 Platform:
   osname=linux, osvers=3.0.0-17-generic, archname=x86_64-linux
   uname='linux zby 3.0.0-17-generic #30-ubuntu smp thu mar 8 20:45:39
utc 2012 x86_64 x86_64 x86_64 gnulinux '
   config_args='-des -Dprefix=/home/zby/localperl -Dusedevel'
   hint=recommended, useposix=true, d_sigaction=define
   useithreads=undef, usemultiplicity=undef
   useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
   use64bitint=define, use64bitall=define, uselongdouble=undef
   usemymalloc=n, bincompat5005=undef
 Compiler:
   cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
   optimize='-O2',
   cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
   ccversion='', gccversion='4.6.1', gccosandvers=''
   intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
   d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
   ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
   alignbytes=8, prototype=define
 Linker and Libraries:
   ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
   libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
   libs=-lnsl -ldl -lm -lcrypt -lutil -lc
   perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
   libc=, so=so, useshrplib=false, libperl=libperl.a
   gnulibc_version='2.13'
 Dynamic Linking:
   dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
   cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.15.9:
   /home/zby/localperl/lib/site_perl/5.15.9/x86_64-linux
   /home/zby/localperl/lib/site_perl/5.15.9
   /home/zby/localperl/lib/5.15.9/x86_64-linux
   /home/zby/localperl/lib/5.15.9
   .

---
Environment for perl 5.15.9:
   HOME=/home/zby
   LANG=pl_PL.UTF-8
   LANGUAGE (unset)
   LD_LIBRARY_PATH (unset)
   LOGDIR (unset)
   PATH=/home/zby/perl5/perlbrew/bin:/home/zby/perl5/perlbrew/perls/perl-5.14.0/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
   PERLBREW_PATH=/home/zby/perl5/perlbrew/bin:/home/zby/perl5/perlbrew/perls/perl-5.14.0/bin
   PERLBREW_PERL=perl-5.14.0
   PERLBREW_ROOT=/home/zby/perl5/perlbrew
   PERLBREW_VERSION=0.13
   PERL_BADLANG (unset)
   SHELL=/bin/bash


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About