From: Karen Etheridge Date: Sat, 30 Mar 2013 02:02:08 +0000 (-0700) Subject: fix hash order randomization issue: use canonical mode with JSON (RT#84287) X-Git-Tag: 0.33~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f80d4038446bbbc3c1abfc467a5fe2b81c1c404;p=gitmo%2FMooseX-Storage.git fix hash order randomization issue: use canonical mode with JSON (RT#84287) --- diff --git a/Changes b/Changes index 14ee149..f92a0f6 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for MooseX-Storage + * always JSONify data with sorted keys, to handle hash order randomization + introduced in 5.17.* (RT#84287, Karen Etheridge) + 0.32 * Change to use core Digest and Digest::SHA dists, rather than Digest::SHA1. RT#69811 diff --git a/lib/MooseX/Storage/Format/JSON.pm b/lib/MooseX/Storage/Format/JSON.pm index bc8316c..1afda1b 100644 --- a/lib/MooseX/Storage/Format/JSON.pm +++ b/lib/MooseX/Storage/Format/JSON.pm @@ -21,7 +21,7 @@ sub thaw { sub freeze { my ( $self, @args ) = @_; - my $json = JSON::Any->new->objToJson( $self->pack(@args) ); + my $json = JSON::Any->new(canonical => 1)->objToJson( $self->pack(@args) ); utf8::decode($json) if !utf8::is_utf8($json) and utf8::valid($json); # if it's valid utf8 mark it as such return $json; }