Skip to content

Commit

Permalink
add quotemeta to protect callback_key, and test
Browse files Browse the repository at this point in the history
  • Loading branch information
fcuny committed Sep 29, 2010
1 parent 1251d51 commit d5a72bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Plack/Middleware/JSONP.pm
Expand Up @@ -13,7 +13,7 @@ sub call {
my $res = shift;
if (defined $res->[2] && ref $res->[2] eq 'ARRAY' && @{$res->[2]} == 1) {
my $h = Plack::Util::headers($res->[1]);
my $callback_key = $self->callback_key || 'callback';
my $callback_key = quotemeta($self->callback_key) || 'callback';
if ($h->get('Content-Type') =~ m!/(?:json|javascript)! &&
$env->{QUERY_STRING} =~ /(?:^|&)$callback_key=([^&]+)/) {
my $cb = URI::Escape::uri_unescape($1);
Expand Down
2 changes: 1 addition & 1 deletion t/Plack-Middleware/jsonp.t
Expand Up @@ -7,7 +7,7 @@ my $json = '{"foo":"bar"}';

my @tests = (
{
callback_key => 'jsonp',
callback_key => 'json.p',
app => sub {
return [ 200, [ 'Content-Type' => 'application/json' ], [$json] ];
},
Expand Down

0 comments on commit d5a72bf

Please sign in to comment.