mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-02 08:26:22 +01:00
api/cookie: validate cookie file format
This commit is contained in:
parent
31d65c9fb7
commit
3d95361c09
1 changed files with 8 additions and 3 deletions
|
@ -35,10 +35,15 @@ const setupMain = async (cookiePath) => {
|
||||||
for (const serviceName in cookies) {
|
for (const serviceName in cookies) {
|
||||||
if (!VALID_SERVICES.has(serviceName)) {
|
if (!VALID_SERVICES.has(serviceName)) {
|
||||||
console.warn(`${Yellow('[!]')} ignoring unknown service in cookie file: ${serviceName}`);
|
console.warn(`${Yellow('[!]')} ignoring unknown service in cookie file: ${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];
|
invalidCookies[serviceName] = cookies[serviceName];
|
||||||
delete cookies[serviceName];
|
delete cookies[serviceName];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
intervalId = setInterval(() => writeChanges(cookiePath), WRITE_INTERVAL);
|
intervalId = setInterval(() => writeChanges(cookiePath), WRITE_INTERVAL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue