Take the Expires of a cookie an action sets right in the web client

Open Beginner friendly
#2,026 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
web-dev

Research direction

The conversion happens where the web client turns a Set-Cookie header's Expires attribute into a max age; grep the web-client module for Expires and for the place the cookie's max age is set. Replace the locale-dependent parse with an English-locale parser accepting both EEE, dd MMM yyyy HH:mm:ss zzz and EEE, dd-MMM-yyyy HH:mm:ss zzz, then use the seconds remaining until that date, clamped to 0 when it is in the past. Done means a cookie set with either form keeps the right lifetime and a past date deletes it.

Written by the indexing model from the issue text.

Description

Description

An action called over HTTP can set the cookies of its response in System.cookiesTo, with the attributes after the value:

setSession() {
    cookiesTo('session') <- 'abc; Expires=Thu, 26 Nov 2026 12:00:00 GMT; Path=/';
}

The server's own HTTP port passes the attributes on as they are. The web client turns Expires into the cookie's max age, and gets it wrong:

  • the date is read in the language of the web client's JVM, so where that language is not English, every Expires makes the call fail with a NullPointerException;
  • the form with dashes, Thu, 26-Nov-2026 12:00:00 GMT, which many servers send, fails the same way in any language;
  • where the date is read, the max age is set in milliseconds, though it is in seconds: a cookie that expires in a day is kept for about a thousand days, past about 25 days the number overflows, so that the cookie is dropped when the browser closes or kept for years, and an Expires in the past, which should delete the cookie, does not.

Max-Age itself is passed on right.

Reason

A cookie the application sets for a while, or deletes, behaves differently through the web client than through the server's own port, and on a web client in another language the call fails altogether.

Fix

The web client reads Expires in both of its forms in English, whatever its language, and turns it into the number of seconds left, 0 for a date in the past.

Dominant language
Java
Stars
214
Forks
46
PR merge metrics
No merged PRs in 30d

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lsfusion/platform

All issues in lsfusion/platform

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.