merged branch jfsimon/issue-7039 (PR #7347)

This PR was merged into the 2.1 branch.

Commits
-------

fc47589 [BrowserKit] added ability to ignored malformed set-cookie header

Discussion
----------

[BrowserKit] adds ability to ignore malformed set-cookie header

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7039
This commit is contained in:
Fabien Potencier 2013-03-12 19:25:55 +01:00
commit 940d591dc2
2 changed files with 12 additions and 1 deletions

View File

@ -109,7 +109,11 @@ class CookieJar
}
foreach ($cookies as $cookie) {
$this->set(Cookie::fromString($cookie, $uri));
try {
$this->set(Cookie::fromString($cookie, $uri));
} catch (\InvalidArgumentException $e) {
// invalid cookies are just ignored
}
}
}

View File

@ -82,6 +82,13 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies');
}
public function testUpdateFromEmptySetCookie()
{
$cookieJar = new CookieJar();
$cookieJar->updateFromSetCookie(array(''));
$this->assertEquals(array(), $cookieJar->all());
}
public function testUpdateFromSetCookieWithMultipleCookies()
{
$timestamp = time() + 3600;