Fix periods in jsonp param name. RT#73741
Tomas Doran [Wed, 4 Jan 2012 19:34:03 +0000 (19:34 +0000)]
Changes
lib/Catalyst/Action/Serialize/JSONP.pm
t/jsonp.t

diff --git a/Changes b/Changes
index fb7d010..b79fa72 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+  Fix regex for JSONP parameter name to be able to include the . chatacter
+  in Catalyst::Action::Serialize::JSONP. RT#73741
+
   Add optional location parameter to status_acceped handler. RT#73691 (ghenry)
 
 Fri  09 Dec 2011 08:35:00 GMT - Release 0.94
index f450fde..105e016 100644 (file)
@@ -19,7 +19,7 @@ after 'execute' => sub {
 
   my $callback_value = $c->req->param($callback_key);
   if ($callback_value) {
-    if ($callback_value =~ /^\w+$/) {
+    if ($callback_value =~ /^[.\w]+$/) {
       $c->res->content_type('text/javascript');
       $c->res->output($callback_value.'('.$c->res->output().');');
     } else {
index 97a77cd..f5b884a 100644 (file)
--- a/t/jsonp.t
+++ b/t/jsonp.t
@@ -19,10 +19,10 @@ for ('text/javascript','application/x-javascript','application/javascript') {
     my $t = Test::Rest->new('content_type' => $_);
     my $monkey_template = { monkey => 'likes chicken!' };
 
-    my $mres = request($t->get(url => '/monkey_get?callback=omnivore'));
+    my $mres = request($t->get(url => '/monkey_get?callback=My_Animal.omnivore'));
     ok( $mres->is_success, 'GET the monkey succeeded' );
 
-    my ($json_param) = $mres->content =~ /^omnivore\((.*)?\);$/;
+    my ($json_param) = $mres->content =~ /^My_Animal.omnivore\((.*)?\);$/;
     is_deeply($json->decode($json_param), $monkey_template, "GET returned the right data");
 }