Skip to content

[HttpFoundation] Expired cookies string representation consistency & tests #38369

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

Merged
merged 1 commit into from
Oct 4, 2020

Conversation

iquito
Copy link
Contributor

@iquito iquito commented Oct 1, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
License MIT

These changes add consistent behavior when converting expired cookies back and forth from string representation into Symfony\Component\HttpFoundation\Cookie instances in Cookie::fromString:

  • When Max-Age is zero and expires is in the past, the expires date is kept as is (previous behavior: expires is overwritten with current timestamp because it is reset to current timestamp + Max-Age)
  • When Max-Age is zero and expires is in the future, expires is reset to current timestamp, as Max-Age is the preferred "source of truth" (same as previous behavior)
  • Add tests for how the Cookie class handles Max-Age in a cookie string and how expires and Max-Age interact
  • Extract helper function expiresTimestamp so converting to a unix timestamp can be reused in Cookie::fromString

This is more a new feature than a bug fix in my mind, therefore I would include it in 5.1+.

@fabpot
Copy link
Member

fabpot commented Oct 4, 2020

Thank you @iquito.

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

Successfully merging this pull request may close these issues.

5 participants