From cfa7ecd7f8a00b027c19299624bfb4aa8869b380 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 16 Aug 2022 09:35:17 +0200 Subject: [PATCH] fix: Add missing validation to document state --- server/models/Document.ts | 4 ++++ shared/validations.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/server/models/Document.ts b/server/models/Document.ts index 68cdd5565..c7f522017 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -228,6 +228,10 @@ class Document extends ParanoidModel { @Column(DataType.TEXT) text: string; + @Length({ + max: DocumentValidation.maxStateLength, + msg: `Document collaborative state is too large, you must create a new document`, + }) @Column(DataType.BLOB) state: Uint8Array; diff --git a/shared/validations.ts b/shared/validations.ts index efa510239..6bdd74f70 100644 --- a/shared/validations.ts +++ b/shared/validations.ts @@ -30,6 +30,9 @@ export const CollectionValidation = { export const DocumentValidation = { /** The maximum length of the document title */ maxTitleLength: 100, + + /** The maximum size of the collaborative document state */ + maxStateLength: 1000000, }; export const PinValidation = {