8000 [HttpFoundation] Fix to prevent magic bytes injection in JSONP respon… · symfony/symfony@6af3d05 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6af3d05

Browse files
author
Andrew Moore
committed
[HttpFoundation] Fix to prevent magic bytes injection in JSONP responses (Prevents CVE-2014-4671)
1 parent ca69dbb commit 6af3d05

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/HttpFoundation/JsonResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function update()
111111
// Not using application/javascript for compatibility reasons with older browsers.
112112
$this->headers->set('Content-Type', 'text/javascript');
113113

114-
return $this->setContent(sprintf('%s(%s);', $this->callback, $this->data));
114+
return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data));
115115
}
116116

117117
// Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback)

src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function testSetCallback()
155155
{
156156
$response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback');
157157

158-
$this->assertEquals('callback({"foo":"bar"});', $response->getContent());
158+
$this->assertEquals('/**/callback({"foo":"bar"});', $response->getContent());
159159
$this->assertEquals('text/javascript', $response->headers->get('Content-Type'));
160160
}
161161

0 commit comments

Comments
 (0)
0