From c7657ae81e23102cedd31543ee111d2736dc3b22 Mon Sep 17 00:00:00 2001 From: Max Wu Date: Sat, 10 Mar 2018 16:52:24 +0800 Subject: [PATCH] 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/models/note.js b/lib/models/note.js index 119d72c34..dc4d187b3 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -209,15 +209,6 @@ module.exports = function (sequelize, DataTypes) { return _callback(err, null) }) }, - parseNoteIdByBase64Url: function (_callback) { - // try to parse note id by base64url - try { - 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) - } - }, // parse note id by LZString is deprecated, here for compability parseNoteIdByLZString: function (_callback) { // try to parse note id by LZString Base64 @@ -228,6 +219,15 @@ module.exports = function (sequelize, DataTypes) { return _callback(err, null) } }, + parseNoteIdByBase64Url: function (_callback) { + // try to parse note id by base64url + try { + 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) + } + }, parseNoteIdByShortId: function (_callback) { // try to parse note id by shortId try {