Front page | perl.perl5.porters |
Postings from January 2012
[perl #107830] Data::Dumper incorrectly serializes qr(\Q/\E)
Thread Next
From:
Adam Thomason
Date:
January 10, 2012 00:16
Subject:
[perl #107830] Data::Dumper incorrectly serializes qr(\Q/\E)
Message ID:
rt-3.6.HEAD-14510-1326167772-302.107830-75-0@perl.org
# New Ticket Created by Adam Thomason
# Please include the string: [perl #107830]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=107830 >
This is a bug report for perl from athomason@cpan.org,
generated with the help of perlbug 1.39 running under perl 5.14.2.
-----------------------------------------------------------------
Data::Dumper incorrectly serializes regex objects in which a / character is
escaped within a \Q\E construct. For example:
use Data::Dumper;
my $rx = qr(\Q/\E);
print "$rx\n";
my $dumped = Dumper($rx);
print "$dumped\n";
eval $dumped;
print "$@\n";
outputs:
(?^:\/)
$VAR1 = qr/(?^:\\/)/;
Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE ?^:\\/ at
(eval 1) line 1.
Compare to the output of the same program without \Q\E:
(?^:/)
$VAR1 = qr/(?^:\/)/;
This is because perl's stringifier chooses to escape the / in the first
version, but not the second. While arguably unnecessary, that behavior is
consistent with the documentation of quotemeta. However, it breaks DD's
attempt
to construct a qr string because of
[http://perl5.git.perl.org/perl.git/blob/HEAD:/dist/Data-Dumper/Dumper.pm#l376]
$pat =~ s,/,\\/,g;
which incorrectly causes the doubling of the escaping \, leading to the
regex
being terminated early.
The escaping code on line 376 was introduced in 4ab99479, without particular
comment to its necessity. Removing it doesn't break DD's test suite, but
it's
quite possible it breaks something else, perhaps an older perl which
stringifies regexes differently.
Tested under perl 5.14.2 with DD 2.130_02 and 5.8.9 with 2.121_17.
-----------------------------------------------------------------
---
Flags:
category=library
severity=medium
---
Site configuration information for perl 5.14.2:
Configured by pigeon at Tue Jan 3 17:15:23 PST 2012.
Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
Platform:
osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux
uname='linux pigeon-shared 2.6.32-5-amd64 #1 smp tue jun 14
09:42:28 utc 2011 x86_64 gnulinux '
config_args='-de
-Dprefix=/home/pigeon/pigeon/extlib/perls/perl-5.14.2 -Duserelocatableinc'
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.4.5', 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/../lib /usr/lib/../lib /lib /usr/lib
/lib64 /usr/lib64
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.11.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11.2'
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.14.2:
/usr/local/pigeon/extlib/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux
/usr/local/pigeon/extlib/perls/perl-5.14.2/lib/site_perl/5.14.2
/usr/local/pigeon/extlib/perls/perl-5.14.2/lib/5.14.2/x86_64-linux
/usr/local/pigeon/extlib/perls/perl-5.14.2/lib/5.14.2
.
---
Environment for perl 5.14.2:
HOME=/u/athomason
LANG=en_US
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/lib/ccache:/usr/lib64/ccache/bin:/u/athomason/bin:/u/athomason/perl5/perlbrew/bin:/u/athomason/perl5/perlbrew/perls/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin
PERL_BADLANG (unset)
SHELL=/bin/tcsh
Thread Next
-
[perl #107830] Data::Dumper incorrectly serializes qr(\Q/\E)
by Adam Thomason