mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-26 17:38:28 +03:00
Add another validity filter
This commit is contained in:
@@ -108,12 +108,32 @@ export async function canSubmit(userID: HashedUserID, category: Category): Promi
|
||||
}
|
||||
}
|
||||
|
||||
export function validSubmittedData(userAgent: string): boolean {
|
||||
export function validSubmittedData(userAgent: string, userAgentR: string): boolean {
|
||||
if (!config.validityCheck.userAgent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !new RegExp(config.validityCheck.userAgent).test(userAgent);
|
||||
for (const key of Object.keys(config.validityCheck)) {
|
||||
const check = (config.validityCheck as Record<string, string | null>)[key];
|
||||
if (check === null) {
|
||||
continue;
|
||||
} else {
|
||||
switch (key) {
|
||||
case "userAgent":
|
||||
if (!userAgent.match(check)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "userAgentR":
|
||||
if (!userAgentR.match(new RegExp(check))) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function canSubmitGlobal(userID: HashedUserID): Promise<CanSubmitGlobalResult> {
|
||||
|
||||
Reference in New Issue
Block a user