From b093569ec55e828bb8e382486521fd5347f00faf Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 18 Dec 2020 21:23:51 +0100 Subject: [PATCH 1/5] increase toast size limit --- src/public/app/services/sync.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/app/services/sync.js b/src/public/app/services/sync.js index d3b20e7e5..52b491a5e 100644 --- a/src/public/app/services/sync.js +++ b/src/public/app/services/sync.js @@ -8,8 +8,8 @@ async function syncNow() { toastService.showMessage("Sync finished successfully."); } else { - if (result.message.length > 100) { - result.message = result.message.substr(0, 100); + if (result.message.length > 200) { + result.message = result.message.substr(0, 200); } toastService.showError("Sync failed: " + result.message); From eaf93a70cdea3f52e073ddd07c6c108e2ac3de3c Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 21 Dec 2020 20:55:01 +0100 Subject: [PATCH 2/5] fix inverse relation creation, closes #1498 --- src/public/app/services/sync.js | 2 +- src/services/handlers.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/public/app/services/sync.js b/src/public/app/services/sync.js index 52b491a5e..8076a7937 100644 --- a/src/public/app/services/sync.js +++ b/src/public/app/services/sync.js @@ -9,7 +9,7 @@ async function syncNow() { } else { if (result.message.length > 200) { - result.message = result.message.substr(0, 200); + result.message = result.message.substr(0, 200) + "..."; } toastService.showError("Sync failed: " + result.message); diff --git a/src/services/handlers.js b/src/services/handlers.js index 96ee9e0dc..6ac5d5c1f 100644 --- a/src/services/handlers.js +++ b/src/services/handlers.js @@ -94,10 +94,10 @@ eventService.subscribe(eventService.CHILD_NOTE_CREATED, ({ parentNote, childNote function processInverseRelations(entityName, entity, handler) { if (entityName === 'attributes' && entity.type === 'relation') { const note = entity.getNote(); - const attributes = (note.getOwnedAttributes(entity.name)).filter(relation => relation.type === 'relation-definition'); + const relDefinitions = note.getLabels('relation:' + entity.name); - for (const attribute of attributes) { - const definition = attribute.value; + for (const relDefinition of relDefinitions) { + const definition = relDefinition.getDefinition(); if (definition.inverseRelation && definition.inverseRelation.trim()) { const targetNote = entity.getTargetNote(); From fc4edf4aa713a258cd78f6c1f8ef00bbc4f4e770 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 21 Dec 2020 21:05:34 +0100 Subject: [PATCH 3/5] better comment for instanceName --- config-sample.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-sample.ini b/config-sample.ini index 8393c8725..7829089b1 100644 --- a/config-sample.ini +++ b/config-sample.ini @@ -1,5 +1,5 @@ [General] -# Instance name can be used to distinguish between different instances +# Instance name can be used to distinguish between different instances using backend api.getInstanceName() instanceName= # set to true to allow using Trilium without authentication (makes sense for server build only, desktop build doesn't need password) From 7133e60267beea701b99ab0a870a851fe3cb43dd Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 21 Dec 2020 22:08:55 +0100 Subject: [PATCH 4/5] make encryption more robust in face of null values, #1483 --- src/services/protected_session.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/services/protected_session.js b/src/services/protected_session.js index ebf4b998f..f224ed6f1 100644 --- a/src/services/protected_session.js +++ b/src/services/protected_session.js @@ -43,10 +43,18 @@ function decryptNotes(notes) { } function encrypt(plainText) { + if (plainText === null) { + return null; + } + return dataEncryptionService.encrypt(getDataKey(), plainText); } function decrypt(cipherText) { + if (cipherText === null) { + return null; + } + return dataEncryptionService.decrypt(getDataKey(), cipherText); } From bdfd760b9d428dc29c45a0e016d12a25af220043 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 21 Dec 2020 23:19:03 +0100 Subject: [PATCH 5/5] fixed some encryption issues --- src/services/data_encryption.js | 10 +++++++++- src/services/note_cache/entities/note.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/services/data_encryption.js b/src/services/data_encryption.js index 104081910..9ef10f484 100644 --- a/src/services/data_encryption.js +++ b/src/services/data_encryption.js @@ -52,6 +52,10 @@ function encrypt(key, plainText, ivLength = 13) { } function decrypt(key, cipherText, ivLength = 13) { + if (cipherText === null) { + return null; + } + if (!key) { return "[protected]"; } @@ -93,6 +97,10 @@ function decrypt(key, cipherText, ivLength = 13) { function decryptString(dataKey, cipherText) { const buffer = decrypt(dataKey, cipherText); + if (buffer === null) { + return null; + } + const str = buffer.toString('utf-8'); if (str === 'false') { @@ -108,4 +116,4 @@ module.exports = { encrypt, decrypt, decryptString -}; \ No newline at end of file +}; diff --git a/src/services/note_cache/entities/note.js b/src/services/note_cache/entities/note.js index 6793ad476..d2eeda928 100644 --- a/src/services/note_cache/entities/note.js +++ b/src/services/note_cache/entities/note.js @@ -338,7 +338,7 @@ class Note { decrypt() { if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) { - this.title = protectedSessionService.decryptString(note.title); + this.title = protectedSessionService.decryptString(this.title); this.isDecrypted = true; }