Skip to content

Commit 5c098e1

Browse files
Arnoldas Grigutistobias-93
authored andcommitted
Protection against rosetta flash attacks
1 parent 27d424e commit 5c098e1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Controller/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function indexAction(Request $request, $_format)
110110
throw new HttpException(400, 'Invalid JSONP callback value');
111111
}
112112

113-
$content = $callback.'('.$content.');';
113+
$content = '/**/' . $callback . '(' . $content . ');';
114114
}
115115

116116
$response = new Response($content, 200, array('Content-Type' => $request->getMimeType($_format)));

Tests/Controller/ControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testGenerateWithCallback($callback)
6666
$response = $controller->indexAction($this->getRequest('/', 'GET', array('callback' => $callback)), 'json');
6767

6868
$this->assertEquals(
69-
sprintf('%s({"base_url":"","routes":[],"prefix":"","host":"","scheme":""});', $callback),
69+
sprintf('/**/%s({"base_url":"","routes":[],"prefix":"","host":"","scheme":""});', $callback),
7070
$response->getContent()
7171
);
7272
}

0 commit comments

Comments
 (0)