mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-22 10:46:19 +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,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);
|
||||
|
|
Loading…
Reference in a new issue