Added fix for RT 63537 (from Gerv) and tests to check it.
[catagits/Catalyst-Action-REST.git] / t / lib / Test / Serialize / Controller / REST.pm
index 118e237..8c1d5f2 100644 (file)
@@ -27,13 +27,22 @@ __PACKAGE__->config(
         '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" ) {
-        my $out = $c->req->data->{'sushi'} . $c->req->data->{'chicken'}||'';
+        my $out = ($c->req->data->{'sushi'}||'') . ($c->req->data->{'chicken'}||'');
         utf8::encode($out);
         $c->res->output( $out );
     } else {
@@ -46,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;