Skip to content

Commit 1012111

Browse files
authored
Merge pull request #797 from SISheogorath/fix/LZErrorLog
Add check for noteId length
2 parents 387afd1 + 735b806 commit 1012111

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/models/note.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ module.exports = function (sequelize, DataTypes) {
211211
},
212212
// parse note id by LZString is deprecated, here for compability
213213
parseNoteIdByLZString: function (_callback) {
214+
// Calculate minimal string length for an UUID that is encoded
215+
// base64 encoded and optimize comparsion by using -1
216+
// this should make a lot of LZ-String parsing errors obsolete
217+
// as we can assume that a nodeId that is 48 chars or longer is a
218+
// noteID.
219+
const base64UuidLength = ((4 * 36) / 3) - 1
220+
if (!(noteId.length > base64UuidLength)) {
221+
return _callback(null, null)
222+
}
214223
// try to parse note id by LZString Base64
215224
try {
216225
var id = LZString.decompressFromBase64(noteId)

0 commit comments

Comments
 (0)