Front page | perl.perl5.porters |
Postings from November 2014
[perl #123319] make HTML output reproducable with CGI.pm
From:
perlbug-followup
Date:
November 30, 2014 21:01
Subject:
[perl #123319] make HTML output reproducable with CGI.pm
Message ID:
rt-4.0.18-6339-1417164773-1555.123319-75-0@perl.org
# New Ticket Created by
# Please include the string: [perl #123319]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=123319 >
This is a bug report for perl from meissner@suse.de,
generated with the help of perlbug 1.40 running under perl 5.20.1.
-----------------------------------------------------------------
Hi,
I am using CGI.pm to create HTML output. Due to hashes now being
randomized the "keys %hash" returns the keys in a random order.
Due to this CGI.pm of this perl version creates HTML that changes on
every invocation.
I have added some sorts to keys so it creates constant HTML output.
It probably does not cover all cases, just the ones in my usecase.
Ciao, Marcus
--- CGI.pm.fix 2014-11-24 17:36:51.281993992 +0100
+++ CGI.pm 2014-11-24 17:36:52.873993231 +0100
@@ -1705,7 +1705,7 @@
}
if ($meta && ref($meta) && (ref($meta) eq 'HASH')) {
- for (keys %$meta) { push(@result,$XHTML ? qq(<meta name="$_" content="$meta->{$_}" />)
+ for (sort keys %$meta) { push(@result,$XHTML ? qq(<meta name="$_" content="$meta->{$_}" />)
: qq(<meta name="$_" content="$meta->{$_}">)); }
}
--- CGI/Util.pm.xx 2014-11-24 17:47:02.016544717 +0100
+++ CGI/Util.pm 2014-11-24 17:47:05.583541202 +0100
@@ -154,7 +154,7 @@
my $value = $escape ? simple_escape($attr->{$_}) : $attr->{$_};
push(@att,defined($attr->{$_}) ? qq/$key=$quote$value$quote/ : qq/$key/);
}
- return @att;
+ return sort @att;
}
sub simple_escape {
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
This perlbug was built using Perl 5.20.1 - Mon Oct 6 09:13:55 UTC 2014
It is being executed now by Perl 5.20.1 - Mon Oct 6 09:11:27 UTC 2014.
Site configuration information for perl 5.20.1:
Configured by abuild at Mon Oct 6 09:11:27 UTC 2014.
Summary of my perl5 (revision 5 version 20 subversion 1) configuration:
Platform:
osname=linux, osvers=3.16.3-1.gd2bbe7f-default, archname=x86_64-linux-thread-multi
uname='linux cloud115 3.16.3-1.gd2bbe7f-default #1 smp thu sep 18 06:32:16 utc 2014 (d2bbe7f) x86_64 x86_64 x86_64 gnulinux '
config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Dd_dbm_open -Duseshrplib=true -Doptimize=-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe -Accflags=-DPERL_USE_SAFE_PUTENV -Dotherlibdirs=/usr/lib/perl5/site_perl -Dinc_version_list=5.20.0/x86_64-linux-thread-multi 5.20.0'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fwrapv -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fwrapv -fno-strict-aliasing -pipe -fstack-protector'
ccversion='', gccversion='4.8.3 20140627 [gcc-4_8-branch revision 212064]', 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 =' -L/usr/local/lib64 -fstack-protector'
libpth=/usr/local/lib /usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
libs=-lm -ldl -lcrypt -lpthread
perllibs=-lm -ldl -lcrypt -lpthread
libc=/lib64/libc-2.19.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.19'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.20.1/x86_64-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64 -fstack-protector'
---
@INC for perl 5.20.1:
/suse/meissner/perl5/lib/perl5/x86_64-linux-thread-multi
/suse/meissner/perl5/lib/perl5
/usr/lib/perl5/site_perl/5.20.1/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.20.1
/usr/lib/perl5/vendor_perl/5.20.1/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.20.1
/usr/lib/perl5/5.20.1/x86_64-linux-thread-multi
/usr/lib/perl5/5.20.1
/usr/lib/perl5/site_perl
.
---
Environment for perl 5.20.1:
HOME=/suse/meissner
LANG=de_DE.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/suse/meissner/perl5/bin:/suse/meissner/bin:/suse/meissner/perl5/bin:/suse/meissner/bin:/suse/meissner/perl5/bin:/suse/meissner/bin:/suse/meissner/perl5/bin:/suse/meissner/bin:/suse/meissner/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin
PERL5LIB=/suse/meissner/perl5/lib/perl5/x86_64-linux-thread-multi:/suse/meissner/perl5/lib/perl5
PERL_BADLANG (unset)
PERL_LOCAL_LIB_ROOT=/suse/meissner/perl5
PERL_MB_OPT=--install_base /suse/meissner/perl5
PERL_MM_OPT=INSTALL_BASE=/suse/meissner/perl5
SHELL=/bin/bash
-
[perl #123319] make HTML output reproducable with CGI.pm
by perlbug-followup