diff options
author | Max Wu | 2018-03-10 16:52:24 +0800 |
---|---|---|
committer | Max Wu | 2018-03-10 16:52:24 +0800 |
commit | c7657ae81e23102cedd31543ee111d2736dc3b22 (patch) | |
tree | 7778936e666d613bb32f2d0da48fdc922e18deab | |
parent | 16cb842b946d55668318c08cf2e0aed001b9f855 (diff) |
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 <jackymaxj@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | lib/models/note.js | 14 |
1 files changed, 7 insertions, 7 deletions
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) |