Issue with "=" at the end of a koa-session encoded property
fessacchiotto opened this issue · comments
fessacchiotto commented
Hi!
I'm using node version 20.10.0.
$ nvm list
v18.17.1
v18.18.1
-> v20.10.0
I've assigned an object to a session property:
ctx.session.user = loginData.user;
The koa-session encoding default function terminate the string with a =
. This is not liked here:
// node_modules/cookies/index.js
var RESTRICTED_CHARS_REGEXP = /[;=]/
[...]
if (value && (!fieldContentRegExp.test(value) || RESTRICTED_CHARS_REGEXP.test(value))) {
throw new TypeError('argument value is invalid');
}
as I get the following error:
[2024-01-01T23:08:12.586] [ERROR] stdout - TypeError: argument value is invalid
at new Cookie (/Users/maurizio/projects/ewine/backend/node_modules/cookies/index.js:152:11)
at Cookies.set (/Users/maurizio/projects/ewine/backend/node_modules/cookies/index.js:111:16)
at ContextSession.save (/Users/maurizio/projects/ewine/backend/node_modules/koa-session/lib/context.js:341:22)
at ContextSession.commit (/Users/maurizio/projects/ewine/backend/node_modules/koa-session/lib/context.js:244:16)
at session (/Users/maurizio/projects/ewine/backend/node_modules/koa-session/index.js:46:20)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Any help on how to solve this? Thank you!
fengmk2 commented
try the latest version of cookies
?
fengmk2 commented
I reproduced this issue and will fix it as soon as possible.
You can downgrade cookies to version 0.8.x first.
fengmk2 commented
fengmk2 commented
fixed on pillarjs/cookies@0458556
fessacchiotto commented
Thank you! Happy new year!