Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React-Native] cannot parse expires #35

Open
cnkyrpsgl opened this issue Mar 19, 2020 · 4 comments
Open

[React-Native] cannot parse expires #35

cnkyrpsgl opened this issue Mar 19, 2020 · 4 comments

Comments

@cnkyrpsgl
Copy link

returns Invalid Date for Expires=Thu, 26-Mar-2020 07:55:35 GMT as an example

@nfriedly
Copy link
Owner

nfriedly commented Mar 19, 2020

Oh boy. I guess that's what I get for using the built in Date parser. I suspect it's choking on the dashes in 26-Mar-2020. Amusingly, Firefox mis-interprets them as negatives:

new Date('Thu, 26-Mar-2020 07:55:35 GMT')
//> Date Wed Mar 26 -2020 02:59:33 GMT-0456 (Eastern Standard Time)

Chrome and, by extension, Node.js handle it correctly. As does Safari on mac (13.0.5) and in the iOS simulator (13.2.2). I kind of expected/hoped Safari would give the same error you were getting so that I could at least have a straightforward way or reproducing & testing it :(

Do you know much about automated testing for React Native? If you could make me a test-case that reproduces the error? That would help.

@nfriedly
Copy link
Owner

For context, here is the official algorithm for how to parse the expires field: https://tools.ietf.org/html/rfc6265#section-5.1.1 - using the Date object was just a convenient hack that seemed to work well enough until now. I'm not entirely against implementing it, although I'm a little divided as to weather or not it should be the default.

@Athorcis
Copy link

It seems that replacing the dashes with slashes could work
https://stackoverflow.com/questions/8831338/date-issue-in-firefox/8831539

@nfriedly
Copy link
Owner

nfriedly commented Aug 3, 2023

Note to self: tough-cookie has a spec-compliant parser: https://github.com/salesforce/tough-cookie/blob/v4.1.3/lib/cookie.js#L193

(apparently moving to here for the next version: https://github.com/salesforce/tough-cookie/blob/master/lib/cookie/parseDate.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants