Commit eea38331 authored by Nicholas Bamber's avatar Nicholas Bamber

[svn-upgrade] new version libdata-serializer-perl (0.53)

parent 872003e0
Revision history for Perl extension Data::Serializer
0.53 Mon Jan 10 2011
- Modified tests for XML::Simple - it has sub-dependencies on either XML::Parser or XML::SAX
the test harness was posting a failure if neither of these were present. Now it will treat XML::Simple
as if it weren't installed if it is missing it's own depenencies. This version only modifies the test harness
no modification to module code.
Thanks to the cpantesters automated reporting for finding this.
0.52 Mon Jan 3 2011
- Simplfied object by removing %_internal references, base $serializer object is much simpler now.
This eliminated the need for an overridden DESTROY method, and should truly fix the memory leak
problem originally reported by fabrice@dulaunoy.com, essentially it was confusing the Garbage collector (Fix Bug#39592)
0.51 Wed Dec 29 2010
- Modified JSON deserializer to handle corrupt input (Bug#63259)
Thanks to neil.whelchel@gmail.com for report and patch
0.50 Wed Dec 29 2010
- Modified dedigest function to armor against corrupt input values (Bug#63258)
Thanks to neil.whelchel@gmail.com for report and patch
0.49 Tue Apr 15 2009
- Modified XML::Simple serializer to support options
patch supplied by John Alden <john_a_alden@hotmail.com>
......
......@@ -5,3 +5,4 @@
^Build$
^_build/
^testout/
^MYMETA.yml$
---
name: Data-Serializer
version: 0.49
abstract: 'Modules that serialize data structures'
author:
- Neil Neely (neil@neely.cx)
abstract: Modules that serialize data structures
license: perl
resources:
license: ~
requires:
AutoLoader: 0
Data::Dumper: 2.08
Digest::SHA: 0
Exporter: 0
IO::File: 0
- 'Neil Neely (neil@neely.cx)'
build_requires:
File::Spec: 0
IO::File: 0
Test::More: 0
recommends:
Compress::PPMd: 0
Compress::Zlib: 0
Config::General: 0
Crypt::Blowfish: 0
Crypt::CBC: 0
Data::Denter: 0
Data::Taxi: 0
FreezeThaw: 0
JSON: 0
JSON::Syck: 0
JSON::XS: 0
MIME::Base64: 0
PHP::Serialization: 0
Storable: 0
XML::Dumper: 0
XML::Simple: 0
YAML: 0
YAML::Syck: 0
configure_requires:
Module::Build: 0.36
generated_by: 'Module::Build version 0.3607'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Data-Serializer
provides:
Data::Serializer:
file: lib/Data/Serializer.pm
version: 0.49
version: 0.53
Data::Serializer::Config::General:
file: lib/Data/Serializer/Config/General.pm
version: 0.02
......@@ -82,7 +60,31 @@ provides:
Data::Serializer::YAML::Syck:
file: lib/Data/Serializer/YAML/Syck.pm
version: 0.02
generated_by: Module::Build version 0.31012
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
recommends:
Compress::PPMd: 0
Compress::Zlib: 0
Config::General: 0
Crypt::Blowfish: 0
Crypt::CBC: 0
Data::Denter: 0
Data::Taxi: 0
FreezeThaw: 0
JSON: 0
JSON::Syck: 0
JSON::XS: 0
MIME::Base64: 0
PHP::Serialization: 0
Storable: 0
XML::Dumper: 0
XML::Simple: 0
YAML: 0
YAML::Syck: 0
requires:
AutoLoader: 0
Data::Dumper: 2.08
Digest::SHA: 0
Exporter: 0
IO::File: 0
resources:
license: http://dev.perl.org/licenses/
version: 0.53
# Note: this file was auto-generated by Module::Build::Compat version 0.31012
# Note: this file was auto-generated by Module::Build::Compat version 0.3607
unless (eval "use Module::Build::Compat 0.02; 1" ) {
print "This module requires Module::Build to install itself.\n";
require ExtUtils::MakeMaker;
my $yn = ExtUtils::MakeMaker::prompt
(' Install Module::Build now from CPAN?', 'y');
unless ($yn =~ /^y/i) {
die " *** Cannot install without Module::Build. Exiting ...\n";
}
require Cwd;
require File::Spec;
require CPAN;
# Save this 'cause CPAN will chdir all over the place.
my $cwd = Cwd::cwd();
CPAN::Shell->install('Module::Build::Compat');
CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
or die "Couldn't install Module::Build, giving up.\n";
chdir $cwd or die "Cannot chdir() back to $cwd: $!";
}
eval "use Module::Build::Compat 0.02; 1" or die $@;
Module::Build::Compat->run_build_pl(args => \@ARGV);
my $build_script = 'Build';
$build_script .= '.com' if $^O eq 'VMS';
exit(0) unless(-e $build_script); # cpantesters convention
require Module::Build;
Module::Build::Compat->write_makefile(build_class => 'Module::Build');
......@@ -19,193 +19,174 @@ require Exporter;
@EXPORT = qw( );
@EXPORT_OK = qw( );
$VERSION = '0.49';
# Preloaded methods go here.
{
my %_internal;
my %_fields = (
serializer => 'Data::Dumper',
digester => 'SHA-256',
cipher => 'Blowfish',
encoding => 'hex',
compressor => 'Compress::Zlib',
secret => undef,
portable => '1',
compress => '0',
raw => '0',
options => {},
#transient => '0',
serializer_token => '1',
);
sub new {
my ($class, %args) = @_;
my $dataref = {%_fields};
foreach my $field (keys %_fields) {
$dataref->{$field} = $args{$field} if exists $args{$field};
}
$VERSION = '0.53';
#Global cache of modules we've loaded
my %_MODULES;
my %_fields = (
serializer => 'Data::Dumper',
digester => 'SHA-256',
cipher => 'Blowfish',
encoding => 'hex',
compressor => 'Compress::Zlib',
secret => undef,
portable => '1',
compress => '0',
raw => '0',
options => {},
serializer_token => '1',
);
sub new {
my ($class, %args) = @_;
my $dataref = {%_fields};
foreach my $field (keys %_fields) {
$dataref->{$field} = $args{$field} if exists $args{$field};
}
my $self = $dataref;
bless $self, $class;
return $self;
}
$dataref->{_key} = rand
until $dataref->{_key} && !exists $_internal{$dataref->{_key}};
$_internal{$dataref->{_key}} = $dataref;
my $self = \$dataref->{_key};
bless $self, $class;
#opting to not even warn on this, I don't think anyone ever used it as it never did get published on CPAN.
#If I am wrong and this is in production use, contact me
#if (eval "require Tie::Transient") {
# warn "Support for Tie::Transient is deprecated\n";
#}
#load serializer module if it is defined
return $self;
}
sub _serializer_obj {
my $self = (shift);
my $id = $$self;
my $serializer;
if (@_) {
#if argument, then use it for serializing.
$serializer = (shift);
} else {
$serializer = $_internal{$id}->{serializer};
}
$_internal{$id}->{serializer_obj}->{options} = $self->options();
bless $_internal{$id}->{serializer_obj}, "Data::Serializer::$serializer";
}
sub serializer {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{serializer};
if (@_) {
$_internal{$id}->{serializer} = (shift);
}
return $return;
}
sub digester {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{digester};
if (@_) {
my $value = (shift);
$_internal{$id}->{digester} = $value;
}
return $return;
}
sub cipher {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{cipher};
if (@_) {
$_internal{$id}->{cipher} = (shift);
}
return $return;
}
sub compressor {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{compressor};
if (@_) {
$_internal{$id}->{compressor} = (shift);
}
return $return;
}
sub secret {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{secret};
if (@_) {
$_internal{$id}->{secret} = (shift);
}
return $return;
}
sub encoding {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{encoding};
if (@_) {
$_internal{$id}->{encoding} = (shift);
}
return $return;
}
sub portable {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{portable};
if (@_) {
$_internal{$id}->{portable} = (shift);
}
return $return;
}
sub options {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{options};
if (@_) {
$_internal{$id}->{options} = (shift);
}
return $return;
}
sub compress {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{compress};
if (@_) {
$_internal{$id}->{compress} = (shift);
}
return $return;
}
sub raw {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{raw};
if (@_) {
$_internal{$id}->{raw} = (shift);
}
return $return;
}
sub serializer_token {
my $self = (shift);
my $id = $$self;
my $return = $_internal{$id}->{serializer_token};
if (@_) {
$_internal{$id}->{serializer_token} = (shift);
}
return $return;
}
sub _module_loader {
my $self = (shift);
my $id = $$self;
my $module_name = (shift);
return if (exists $_internal{$id}->{loaded_modules}->{$module_name});
if (@_) {
$module_name = (shift) . "::$module_name";
}
my $package = $module_name;
$package =~ s|::|/|g;
$package .= ".pm";
eval { require $package };
if ($@) {
carp "Data::Serializer error: " .
"Please make sure $package is a properly installed package.\n";
return undef;
}
$_internal{$id}->{loaded_modules}->{$module_name} = 1;
}
sub _serializer_obj {
my $self = (shift);
my $serializer;
if (@_) {
#if argument, then use it for serializing.
$serializer = (shift);
} else {
$serializer = $self->{serializer};
}
$self->{serializer_obj}->{options} = $self->options();
bless $self->{serializer_obj}, "Data::Serializer::$serializer";
}
sub DESTROY {
my $self = (shift);
undef %_internal;
}
sub serializer {
my $self = (shift);
my $return = $self->{serializer};
if (@_) {
$self->{serializer} = (shift);
}
return $return;
}
sub digester {
my $self = (shift);
my $return = $self->{digester};
if (@_) {
my $value = (shift);
$self->{digester} = $value;
}
return $return;
}
sub cipher {
my $self = (shift);
my $return = $self->{cipher};
if (@_) {
$self->{cipher} = (shift);
}
return $return;
}
sub compressor {
my $self = (shift);
my $return = $self->{compressor};
if (@_) {
$self->{compressor} = (shift);
}
return $return;
}
sub secret {
my $self = (shift);
my $return = $self->{secret};
if (@_) {
$self->{secret} = (shift);
}
return $return;
}
sub encoding {
my $self = (shift);
my $return = $self->{encoding};
if (@_) {
$self->{encoding} = (shift);
}
return $return;
}
sub portable {
my $self = (shift);
my $return = $self->{portable};
if (@_) {
$self->{portable} = (shift);
}
return $return;
}
sub options {
my $self = (shift);
my $return = $self->{options};
if (@_) {
$self->{options} = (shift);
}
return $return;
}
sub compress {
my $self = (shift);
my $return = $self->{compress};
if (@_) {
$self->{compress} = (shift);
}
return $return;
}
sub raw {
my $self = (shift);
my $return = $self->{raw};
if (@_) {
$self->{raw} = (shift);
}
return $return;
}
sub serializer_token {
my $self = (shift);
my $return = $self->{serializer_token};
if (@_) {
$self->{serializer_token} = (shift);
}
return $return;
}
sub _module_loader {
my $self = (shift);
my $module_name = (shift);
return if (exists $_MODULES{$module_name});
if (@_) {
$module_name = (shift) . "::$module_name";
}
my $package = $module_name;
$package =~ s|::|/|g;
$package .= ".pm";
eval { require $package };
if ($@) {
carp "Data::Serializer error: " .
"Please make sure $package is a properly installed package.\n";
return undef;
}
$_MODULES{$module_name} = 1;
}
#END of public functions, all following functions are for internal use only
#Documentation follows
=pod
=head1 NAME
Data::Serializer:: - Modules that serialize data structures
......@@ -564,6 +545,7 @@ sub _serialize {
my $serializer_obj = $self->_serializer_obj($method);
return $serializer_obj->serialize(@input);
}
sub _compress {
my $self = (shift);
$self->_module_loader($self->compressor);
......@@ -654,9 +636,10 @@ sub _dedigest {
my $input = (shift);
my $digester = (shift);
$self->_module_loader('Digest');
my ($old_digest) = $input =~ /^([^=]+?)=/;
#my ($old_digest) = $input =~ /^([^=]+?)=/;
$input =~ s/^([^=]+?)=//;
my $old_digest = $1;
return undef unless (defined $old_digest);
$input =~ s/^$old_digest=//;
my $new_digest = $self->_get_digest($input,$digester);
return undef unless ($new_digest eq $old_digest);
return $input;
......
......@@ -13,7 +13,8 @@ sub serialize {
}
sub deserialize {
return JSON->VERSION < 2 ? JSON->new->jsonToObj($_[1]) : JSON->new->decode($_[1]);
#return JSON->VERSION < 2 ? JSON->new->jsonToObj($_[1]) : JSON->new->decode($_[1]);
$_[1] and return JSON->VERSION < 2 ? JSON->new->jsonToObj($_[1]) : JSON->new->decode($_[1]);
}
1;
......
......@@ -22,6 +22,21 @@ foreach my $serializer (qw(XML::Simple)) {
}
}
#
# XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those
# too, and if we don't find them, act like XML::Simple is not installed
#
if (grep {/^XML::Simple$/} @serializers) {
if (eval "require XML::SAX") {
$T->msg("Found XML::SAX to support XML::Simple");
} elsif (eval "require XML::Parser") {
$T->msg("Found XML::Parser to support XML::Simple");
} else {
$T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers);
@serializers = grep {!/^XML::Simple$/} @serializers;
}
}
unless (@serializers) {
$T->begin('0 # Skipped: XML::Simple not installed');
exit;
......
......@@ -55,3 +55,4 @@ foreach my $serializer (@serializers) {
}
}
......@@ -19,6 +19,21 @@ foreach my $serializer (keys %serializers) {
push(@serializers, $serializer);
}
}
#
# XML::Simple has an internal dependency of either XML::SAX or XML::Parser, so we need to test for those
# too, and if we don't find them, act like XML::Simple is not installed
#
if (grep {/^XML::Simple$/} @serializers) {
if (eval "require XML::SAX") {
$T->msg("Found XML::SAX to support XML::Simple");
} elsif (eval "require XML::Parser") {
$T->msg("Found XML::Parser to support XML::Simple");
} else {
$T->msg("Could not find XML::Parser or XML::SAX, removing XML::Simple") unless (@serializers);
@serializers = grep {!/^XML::Simple$/} @serializers;
}
}
$T->msg("No serializers found!!") unless (@serializers);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment