From 566a0d64cc77be508399c869eb7338330e5a7e50 Mon Sep 17 00:00:00 2001 From: Terncode Date: Tue, 17 Nov 2026 20:33:58 +0100 Subject: [PATCH] Limit account settings length --- src/ts/server/api/account.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ts/server/api/account.ts b/src/ts/server/api/account.ts index 6dd369a..cccbe04 100644 --- a/src/ts/server/api/account.ts +++ b/src/ts/server/api/account.ts @@ -1,5 +1,7 @@ import { formatDistanceToNow } from 'date-fns'; -import { ACCOUNT_NAME_MAX_LENGTH, ACCOUNT_NAME_MIN_LENGTH, MIN_CHATLOG_RANGE, MAX_CHATLOG_RANGE, HIDES_PER_PAGE } from '../../common/constants'; +import { + ACCOUNT_NAME_MAX_LENGTH, ACCOUNT_NAME_MIN_LENGTH, MIN_CHATLOG_RANGE, MAX_CHATLOG_RANGE, HIDES_PER_PAGE, MAX_FILTER_WORDS_LENGTH +} from '../../common/constants'; import { UpdateAccountData, AccountSettings, AccountData, ModAction, EntitiesEditorInfo, EntityNameTypes } from '../../common/interfaces'; @@ -22,6 +24,9 @@ export type UpdateSettings = ReturnType; export type RemoveSite = ReturnType; export type GetAccountData = ReturnType; +const MAX_DEFAULT_SERVER_LENGTH = 100; +const MAX_ACTIONS_SETTING_LENGTH = 20000; + type LogAccount = (accountId: ID, message: string) => void; const exclude = [ @@ -83,7 +88,7 @@ function fixAccountSettings(settings: AccountSettings | undefined) { const fixed: Partial = {}; if (settings) { - if (settings.defaultServer !== undefined) { + if (settings.defaultServer !== undefined && `${settings.defaultServer}`.length <= MAX_DEFAULT_SERVER_LENGTH) { fixed.defaultServer = `${settings.defaultServer}`; } @@ -124,10 +129,10 @@ function fixAccountSettings(settings: AccountSettings | undefined) { } if (settings.filterWords !== undefined) { - fixed.filterWords = `${settings.filterWords}`; + fixed.filterWords = `${settings.filterWords}`.substr(0, MAX_FILTER_WORDS_LENGTH); } - if (settings.actions !== undefined) { + if (settings.actions !== undefined && `${settings.actions}`.length <= MAX_ACTIONS_SETTING_LENGTH) { fixed.actions = `${settings.actions}`; }