Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: check properties before adding an attachment

thecodrrfbc4940ed12f
diff --git a/packages/core/collections/attachments.js b/packages/core/collections/attachments.js
index 520c36416..ad91c213b 100644
--- a/packages/core/collections/attachments.js
+++ b/packages/core/collections/attachments.js
@@ -57,6 +57,19 @@ export default class Attachments extends Collection {
const { iv, salt, length, alg, hash, hashType, filename, type } =
attachment;
+
+ if (
+ !iv ||
+ !salt ||
+ !length ||
+ !alg ||
+ !hash ||
+ !hashType ||
+ !filename ||
+ !type
+ )
+ throw new Error("Could not add attachment: all properties are required.");
+
const attachmentItem = {
id: id(),
noteIds: noteId ? [noteId] : [],