From 5a38bf78e11105d55ce3ab7b4b580fa55b7e66f3 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 12 Nov 2023 23:43:04 +0100 Subject: [PATCH] fix content renderer of protected canvas/mermaid notes, closes #4414 --- src/becca/entities/bnote.js | 10 ++-------- src/becca/entities/brevision.js | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.js index 27cad3f26..f3f98fe5c 100644 --- a/src/becca/entities/bnote.js +++ b/src/becca/entities/bnote.js @@ -1156,14 +1156,8 @@ class BNote extends AbstractBeccaEntity { /** @returns {BAttachment} */ getAttachmentByTitle(title) { - return sql.getRows(` - SELECT attachments.* - FROM attachments - WHERE ownerId = ? - AND title = ? - AND isDeleted = 0 - ORDER BY position`, [this.noteId, title]) - .map(row => new BAttachment(row))[0]; + // cannot use SQL to filter by title since it can be encrypted + return this.getAttachments().filter(attachment => attachment.title === title)[0]; } /** diff --git a/src/becca/entities/brevision.js b/src/becca/entities/brevision.js index 09a78db64..de9bfbd82 100644 --- a/src/becca/entities/brevision.js +++ b/src/becca/entities/brevision.js @@ -157,14 +157,8 @@ class BRevision extends AbstractBeccaEntity { /** @returns {BAttachment} */ getAttachmentByTitle(title) { - return sql.getRows(` - SELECT attachments.* - FROM attachments - WHERE ownerId = ? - AND title = ? - AND isDeleted = 0 - ORDER BY position`, [this.revisionId, title]) - .map(row => new BAttachment(row))[0]; + // cannot use SQL to filter by title since it can be encrypted + return this.getAttachments().filter(attachment => attachment.title === title)[0]; } beforeSaving() {