Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc47589

Browse files
committed
[BrowserKit] added ability to ignored malformed set-cookie header
1 parent d77b97c commit fc47589

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/BrowserKit/CookieJar.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ public function updateFromSetCookie(array $setCookies, $uri = null)
109109
}
110110

111111
foreach ($cookies as $cookie) {
112-
$this->set(Cookie::fromString($cookie, $uri));
112+
try {
113+
$this->set(Cookie::fromString($cookie, $uri));
114+
} catch (\InvalidArgumentException $e) {
115+
// invalid cookies are just ignored
116+
}
113117
}
114118
}
115119

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ public function testUpdateFromSetCookie()
8282
$this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies');
8383
}
8484

85+
public function testUpdateFromEmptySetCookie()
86+
{
87+
$cookieJar = new CookieJar();
88+
$cookieJar->updateFromSetCookie(array(''));
89+
$this->assertEquals(array(), $cookieJar->all());
90+
}
91+
8592
public function testUpdateFromSetCookieWithMultipleCookies()
8693
{
8794
$timestamp = time() + 3600;

0 commit comments

Comments
 (0)