X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FDeserialize%2FData%2FSerializer.pm;h=b3cef43ec825c92e33b7638d1163180107a7d322;hb=0e1381b4a58f89c8764463ee71f089f4c65ca081;hp=97eb67c73bae787eed9f833b9c82fc055ce4a32e;hpb=2474828604a779657c1bfa42b1875951ccd43383;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Deserialize/Data/Serializer.pm b/lib/Catalyst/Action/Deserialize/Data/Serializer.pm index 97eb67c..b3cef43 100644 --- a/lib/Catalyst/Action/Deserialize/Data/Serializer.pm +++ b/lib/Catalyst/Action/Deserialize/Data/Serializer.pm @@ -6,10 +6,11 @@ use namespace::autoclean; extends 'Catalyst::Action'; use Data::Serializer; use Safe; +use Scalar::Util qw(openhandle); my $compartment = Safe->new; $compartment->permit_only( qw(padany null lineseq const pushmark list anonhash anonlist refgen leaveeval undef) ); -our $VERSION = '0.88'; +our $VERSION = '0.96'; $VERSION = eval $VERSION; sub execute { @@ -29,14 +30,17 @@ sub execute { } my $body = $c->request->body; if ($body) { - my $rbody; - if ( -f $c->request->body ) { - open( BODY, "<", $c->request->body ); - while ( my $line = ) { + my $rbody = ''; + + if(openhandle $body) { + seek($body, 0, 0); # in case something has already read from it + while ( defined( my $line = <$body> ) ) { $rbody .= $line; } - close(BODY); + } else { + $rbody = $body; } + my $rdata; if ( $serializer eq "Data::Dumper" ) { # Taken from Data::Serialize::Data::Dumper::deserialize, but run within a Safe compartment