From c7657ae81e23102cedd31543ee111d2736dc3b22 Mon Sep 17 00:00:00 2001 From: Max Wu Date: Sat, 10 Mar 2018 16:52:24 +0800 Subject: Fix parseNoteId order to fix some edge case that LZString note url could be parsed by base64url note url and thus return wrong note id Signed-off-by: Max Wu --- lib/models/note.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/models/note.js b/lib/models/note.js index 119d72c3..dc4d187b 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -209,20 +209,20 @@ module.exports = function (sequelize, DataTypes) { return _callback(err, null) }) }, - parseNoteIdByBase64Url: function (_callback) { - // try to parse note id by base64url + // parse note id by LZString is deprecated, here for compability + parseNoteIdByLZString: function (_callback) { + // try to parse note id by LZString Base64 try { - var id = Note.decodeNoteId(noteId) + var id = LZString.decompressFromBase64(noteId) if (id && Note.checkNoteIdValid(id)) { return callback(null, id) } else { return _callback(null, null) } } catch (err) { return _callback(err, null) } }, - // parse note id by LZString is deprecated, here for compability - parseNoteIdByLZString: function (_callback) { - // try to parse note id by LZString Base64 + parseNoteIdByBase64Url: function (_callback) { + // try to parse note id by base64url try { - var id = LZString.decompressFromBase64(noteId) + var id = Note.decodeNoteId(noteId) if (id && Note.checkNoteIdValid(id)) { return callback(null, id) } else { return _callback(null, null) } } catch (err) { return _callback(err, null) -- cgit v1.2.3