develooper Front page | perl.perl5.porters | Postings from November 2014

[perl #123319] make HTML output reproducible with CGI.pm

From:
James E Keenan via RT
Date:
November 28, 2014 13:28
Subject:
[perl #123319] make HTML output reproducible with CGI.pm
Message ID:
rt-4.0.18-32268-1417181280-568.123319-15-0@perl.org
On Fri Nov 28 00:52:53 2014, meissner@suse.de wrote:
> 
> 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 {
> 
> 

Perl 5.20 is the last major version of Perl which will be distributed with CGI.pm.  CGI.pm is no longer maintained by the Perl 5 Porters, so bug reports and requests for features should now go to CGI's own bug tracker.  Please file this report at:

https://github.com/leejo/CGI.pm/issues

Thank you very much.




-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=123319



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