Closed aaa2000 closed 7 years ago
@dbu if we use only date_create, the tests will fail for this format Fri, 31-07-20 08:49:37 GMT
.
But this format is not conform to the rfc https://tools.ietf.org/html/rfc6265#section-5.1.1
month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
it has been added to manage unusual cookie dates, see commit https://github.com/symfony/browser-kit/commit/47f146d9406d695ed1ca8256b41542e367442d2c
Rebase done
I added more tests from library mentioned in php-http/client-common#46 https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js except 01 Jan 1600 00:00:00 GMT
which should not pass because the date before 1601.
Use only the function date_create
all tests pass except Fri, 31-07-20 08:49:37 GMT
. Format that does not appear to comply with RFC.
Maybe, CookieUtil::parseDate
is not really useful.
tests failed on PHP 5.4 and HHVM
I will fix later
http://php.net/manual/en/class.datetime.php#datetime.changelog
5.4.24 The COOKIE constant was changed to reflect RFC 1036 using a four digit year rather than a two digit year (RFC 850) as prior versions.
as hhvm works on master, did we just discover a difference between hhvm and php here?
the php 5.4 build fails on the same things, formatting the date: expected "Friday, 31-Jul-2020 08:49...", but got "Friday, 31-Jul-2020 08:49...".
- unfortunately its cut off before any differences show up.
it seems to me that format(\DateTime::COOKIE)
uses different formats in different versions. as we don't want to test the \DateFormat::format method, maybe just use an explicit formatting string so you can compare with a well known outcome?
Yes it is format(\DateTime::COOKIE)
https://3v4l.org/VpvRp, as you said, I will use use an explicit formatting string. I would do it tonight.
throws an exception when the date can't be parsed and commits squashed
thanks a lot @aaa2000 !
What's in this PR?
Implementation of a cookie-date parsing algorithm mentionned in https://github.com/php-http/client-common/pull/46. I preferred to use a simpler method from https://github.com/symfony/symfony/blob/master/src/Symfony/Component/BrowserKit/Cookie.php#L199.
Example Usage
Checklist