summaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-04-11 22:48:40 +0200
committerGitHub2018-04-11 22:48:40 +0200
commit10121118fbf5681ab3560a5384d06382e5874132 (patch)
tree16a012aaeb826f885ed6de6aa626b33bd228fc9a /lib/models
parent387afd1791d9293c0cf1bc0a9e9d44db7b1cd87e (diff)
parent735b806d5d738ee05509c413fee22dfeb5dfbe7c (diff)
Merge pull request #797 from SISheogorath/fix/LZErrorLog
Add check for noteId length
Diffstat (limited to '')
-rw-r--r--lib/models/note.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/models/note.js b/lib/models/note.js
index 69393dd4..2a048e37 100644
--- a/lib/models/note.js
+++ b/lib/models/note.js
@@ -211,6 +211,15 @@ module.exports = function (sequelize, DataTypes) {
},
// parse note id by LZString is deprecated, here for compability
parseNoteIdByLZString: function (_callback) {
+ // Calculate minimal string length for an UUID that is encoded
+ // base64 encoded and optimize comparsion by using -1
+ // this should make a lot of LZ-String parsing errors obsolete
+ // as we can assume that a nodeId that is 48 chars or longer is a
+ // noteID.
+ const base64UuidLength = ((4 * 36) / 3) - 1
+ if (!(noteId.length > base64UuidLength)) {
+ return _callback(null, null)
+ }
// try to parse note id by LZString Base64
try {
var id = LZString.decompressFromBase64(noteId)