X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTest%2FSerialize%2FController%2FREST.pm;h=8c1d5f25d5d09efd848e73e79f6b91286cb9cfe2;hb=8aa1a2eeb6a2f0170ca8548a3862eb874b07238b;hp=733508a8c197be057f0b96c43d19e5463ba05c1b;hpb=21d3f6aeb5d5150d2709f9a3d0647d21e9d74d9b;p=catagits%2FCatalyst-Action-REST.git diff --git a/t/lib/Test/Serialize/Controller/REST.pm b/t/lib/Test/Serialize/Controller/REST.pm index 733508a..8c1d5f2 100644 --- a/t/lib/Test/Serialize/Controller/REST.pm +++ b/t/lib/Test/Serialize/Controller/REST.pm @@ -1,9 +1,9 @@ package Test::Serialize::Controller::REST; -use warnings; -use strict; +use namespace::autoclean; +use Moose; -use base qw/Catalyst::Controller::REST/; +BEGIN { extends qw/Catalyst::Controller::REST/ }; __PACKAGE__->config( 'namespace' => '', @@ -25,14 +25,26 @@ __PACKAGE__->config( 'text/x-php-serialization' => [ 'Data::Serializer', 'PHP::Serialization' ], 'text/view' => [ 'View', 'Simple' ], + 'text/explodingview' => [ 'View', 'Awful' ], 'text/broken' => 'Broken', + 'text/javascript', => 'JSONP', + 'application/x-javascript' => 'JSONP', + 'application/javascript' => 'JSONP', + 'text/my-csv' => [ + 'Callback', { + deserialize => sub { return {split /,/, shift } }, + serialize => sub { my $d = shift; join ',', %$d } + } + ], }, ); sub monkey_put : Local : ActionClass('Deserialize') { my ( $self, $c ) = @_; if ( ref($c->req->data) eq "HASH" ) { - $c->res->output( $c->req->data->{'sushi'} ); + my $out = ($c->req->data->{'sushi'}||'') . ($c->req->data->{'chicken'}||''); + utf8::encode($out); + $c->res->output( $out ); } else { $c->res->output(1); } @@ -43,4 +55,10 @@ sub monkey_get : Local : ActionClass('Serialize') { $c->stash->{'rest'} = { monkey => 'likes chicken!', }; } +sub xss_get : Local : ActionClass('Serialize') { + my ( $self, $c ) = @_; + $c->stash->{'rest'} = { monkey => 'likes chicken > sushi!', }; +} + + 1;