Skip to content

Commit c2bc707

Browse files
acoultonfabpot
authored andcommitted
fixed detection of secure cookies received over https
BrowserKit's cookie handling only recognises a secure cookie if the cookie option is set and the cookie was set over an https request. The client was not passing the url into the cookiejar update code, causing Cookie::isSecure() to always return false for every cookie. Fixes #7666
1 parent 1454af7 commit c2bc707

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/BrowserKit/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function request($method, $uri, array $parameters = array(), array $files
266266

267267
$response = $this->filterResponse($this->response);
268268

269-
$this->cookieJar->updateFromResponse($response);
269+
$this->cookieJar->updateFromResponse($response, $uri);
270270

271271
$this->redirect = $response->getHeader('Location');
272272

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ public function testRequestCookies()
205205
$this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar');
206206
}
207207

208+
public function testRequestSecureCookies()
209+
{
210+
$client = new TestClient();
211+
$client->setNextResponse(new Response('<html><a href="/foo">foo</a></html>', 200, array('Set-Cookie' => 'foo=bar; path=/; secure')));
212+
$client->request('GET', 'https://www.example.com/foo/foobar');
213+
214+
$this->assertTrue($client->getCookieJar()->get('foo','/','www.example.com')->isSecure());
215+
}
216+
208217
public function testClick()
209218
{
210219
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {

0 commit comments

Comments
 (0)