Skip to content

best way to save what you love

api/cookie: validate cookie file format

jj3d95361c094c
diff --git a/api/src/processing/cookie/manager.js b/api/src/processing/cookie/manager.js
index bb36b9da..a738611e 100644
--- a/api/src/processing/cookie/manager.js
+++ b/api/src/processing/cookie/manager.js
@@ -35,9 +35,14 @@ const setupMain = async (cookiePath) => {
for (const serviceName in cookies) {
if (!VALID_SERVICES.has(serviceName)) {
console.warn(`${Yellow('[!]')} ignoring unknown service in cookie file: ${serviceName}`);
- invalidCookies[serviceName] = cookies[serviceName];
- delete cookies[serviceName];
- }
+ } else if (!Array.isArray(cookies[serviceName])) {
+ console.warn(`${Yellow('[!]')} ${serviceName} in cookies file is not an array, ignoring it`);
+ } else if (cookies[serviceName].some(c => typeof c !== 'string')) {
+ console.warn(`${Yellow('[!]')} cookies file contains non-string value for ${serviceName}`);
+ } else continue;
+
+ invalidCookies[serviceName] = cookies[serviceName];
+ delete cookies[serviceName];
}
intervalId = setInterval(() => writeChanges(cookiePath), WRITE_INTERVAL);