File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ class Cookie
30
30
'D, d M Y H:i:s T ' ,
31
31
'D, d-M-y H:i:s T ' ,
32
32
'D, d-M-Y H:i:s T ' ,
33
+ 'D, d-m-y H:i:s T ' ,
34
+ 'D, d-m-Y H:i:s T ' ,
33
35
'D M j G:i:s Y ' ,
34
36
'D M d H:i:s Y T ' ,
35
37
);
@@ -203,6 +205,11 @@ private static function parseDate($dateValue)
203
205
}
204
206
}
205
207
208
+ // attempt a fallback for unusual formatting
209
+ if (false !== $ date = date_create ($ dateValue , new \DateTimeZone ('GMT ' ))) {
210
+ return $ date ->getTimestamp ();
211
+ }
212
+
206
213
throw new \InvalidArgumentException (sprintf ('Could not parse date "%s". ' , $ dateValue ));
207
214
}
208
215
Original file line number Diff line number Diff line change @@ -56,9 +56,12 @@ public function getExpireCookieStrings()
56
56
return array (
57
57
array ('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT ' ),
58
58
array ('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT ' ),
59
+ array ('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT ' ),
60
+ array ('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT ' ),
59
61
array ('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT ' ),
60
62
array ('foo=bar; expires=Fri Jul 31 08:49:37 2020 ' ),
61
63
array ('foo=bar; expires= \'Fri Jul 31 08:49:37 2020 \'' ),
64
+ array ('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT ' ),
62
65
);
63
66
}
64
67
@@ -86,7 +89,7 @@ public function testFromStringThrowsAnExceptionIfCookieIsNotValid()
86
89
public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid ()
87
90
{
88
91
$ this ->setExpectedException ('InvalidArgumentException ' );
89
- Cookie::FromString ('foo=bar; expires=foo ' );
92
+ Cookie::FromString ('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT ' );
90
93
}
91
94
92
95
public function testFromStringThrowsAnExceptionIfUrlIsNotValid ()
You can’t perform that action at this time.
0 commit comments