ignore invalid cookies expires date format

This commit is contained in:
Christian Flothmann 2017-01-30 15:00:07 +01:00
parent f7ba71db7c
commit f19788dd2e
2 changed files with 4 additions and 5 deletions

View File

@ -213,8 +213,6 @@ class Cookie
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
return $date->format('U'); return $date->format('U');
} }
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
} }
/** /**

View File

@ -88,10 +88,11 @@ class CookieTest extends \PHPUnit_Framework_TestCase
Cookie::fromString('foo'); Cookie::fromString('foo');
} }
public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid() public function testFromStringIgnoresInvalidExpiresDate()
{ {
$this->setExpectedException('InvalidArgumentException'); $cookie = Cookie::fromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT');
Cookie::fromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT');
$this->assertFalse($cookie->isExpired());
} }
public function testFromStringThrowsAnExceptionIfUrlIsNotValid() public function testFromStringThrowsAnExceptionIfUrlIsNotValid()