Skip to content

Commit

Permalink
fix jsonp rosetta flash vulnerability, see http://miki.it/blog/2014/7…
Browse files Browse the repository at this point in the history
  • Loading branch information
monken committed Jul 12, 2014
1 parent acfa27a commit 8b1da82
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Server/View/JSONP.pm
Expand Up @@ -23,7 +23,7 @@ sub process {
if ( $content_type ne 'application/json' ) {
$body = JSON->new->allow_nonref->ascii->encode($body);
}
$c->res->body("$cb($body);");
$c->res->body("/**/$cb($body);");
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion t/server/controller/author.t
Expand Up @@ -34,7 +34,7 @@ test_psgi app, sub {
'text/javascript; charset=UTF-8',
'Content-type'
);
like( $res->content, qr/^jsonp\(.*\);$/ms, 'includes jsonp callback' );
like( $res->content, qr/^\/\*\*\/jsonp\(.*\);$/ms, 'includes jsonp callback' );

ok(
$res = $cb->(
Expand Down
2 changes: 1 addition & 1 deletion t/server/controller/pod.t
Expand Up @@ -59,7 +59,7 @@ test_psgi app, sub {
'text/javascript; charset=UTF-8',
'Content-type'
);
ok( my ($function_args) = $res->content =~ /^foo\((.*)\)/s,
ok( my ($function_args) = $res->content =~ /^\/\*\*\/foo\((.*)\)/s,
'callback included' );
ok( my $jsdata = JSON->new->allow_nonref->decode($function_args),
'decode json' );
Expand Down
4 changes: 2 additions & 2 deletions t/server/controller/source.t
Expand Up @@ -49,7 +49,7 @@ test_psgi app, sub {
)
);
if ( $k =~ /callback=foo/ ) {
ok( my ($function_args) = $res->content =~ /^foo\((.*)\)/s,
ok( my ($function_args) = $res->content =~ /^\/\*\*\/foo\((.*)\)/s,
'JSONP wrapper' );
ok(
my $jsdata
Expand Down Expand Up @@ -90,7 +90,7 @@ test_psgi app, sub {
'text/javascript; charset=UTF-8',
'Content-type'
);
ok( my ($function_args) = $res->content =~ /^foo\((.*)\)/s,
ok( my ($function_args) = $res->content =~ /^\/\*\*\/foo\((.*)\)/s,
'JSONP wrapper' );
ok(
my $jsdata = JSON->new->allow_nonref->decode($function_args),
Expand Down

0 comments on commit 8b1da82

Please sign in to comment.