diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config/default.js | 1 | ||||
-rw-r--r-- | lib/config/environment.js | 2 | ||||
-rw-r--r-- | lib/config/index.js | 2 | ||||
-rw-r--r-- | lib/history.js | 15 | ||||
-rw-r--r-- | lib/models/note.js | 6 |
5 files changed, 23 insertions, 3 deletions
diff --git a/lib/config/default.js b/lib/config/default.js index 5c39a4da..6096bce4 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -3,6 +3,7 @@ module.exports = { domain: '', urlPath: '', + host: '0.0.0.0', port: 3000, urlAddPort: false, allowOrigin: ['localhost'], diff --git a/lib/config/environment.js b/lib/config/environment.js index d850ac9d..6c4ce92f 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -5,7 +5,9 @@ const {toBooleanConfig, toArrayConfig, toIntegerConfig} = require('./utils') module.exports = { domain: process.env.CMD_DOMAIN, urlPath: process.env.CMD_URL_PATH, + host: process.env.CMD_HOST, port: toIntegerConfig(process.env.CMD_PORT), + path: process.env.CMD_PATH, urlAddPort: toBooleanConfig(process.env.CMD_URL_ADDPORT), useSSL: toBooleanConfig(process.env.CMD_USESSL), hsts: { diff --git a/lib/config/index.js b/lib/config/index.js index 8705b10b..ac03fcd4 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -139,7 +139,7 @@ if (config.sessionSecret === 'secret') { // Validate upload upload providers if (['filesystem', 's3', 'minio', 'imgur', 'azure'].indexOf(config.imageUploadType) === -1) { logger.error('"imageuploadtype" is not correctly set. Please use "filesystem", "s3", "minio", "azure" or "imgur". Defaulting to "imgur"') - config.imageUploadType = 'imgur' + config.imageUploadType = 'filesystem' } // figure out mime types for image uploads diff --git a/lib/history.js b/lib/history.js index c7d2472c..9c389bfa 100644 --- a/lib/history.js +++ b/lib/history.js @@ -31,6 +31,15 @@ function getHistory (userid, callback) { history = JSON.parse(user.history) // migrate LZString encoded note id to base64url encoded note id for (let i = 0, l = history.length; i < l; i++) { + // 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 (!(history[i].id.length > base64UuidLength)) { + continue + } try { let id = LZString.decompressFromBase64(history[i].id) if (id && models.Note.checkNoteIdValid(id)) { @@ -38,7 +47,11 @@ function getHistory (userid, callback) { } } catch (err) { // most error here comes from LZString, ignore - logger.error(err) + if (err.message === 'Cannot read property \'charAt\' of undefined') { + logger.warning('Looks like we can not decode "' + history[i].id + '" with LZString. Can be ignored.') + } else { + logger.error(err) + } } } history = parseHistoryToObject(history) diff --git a/lib/models/note.js b/lib/models/note.js index ec7e2b13..0e8dd4dd 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -227,7 +227,11 @@ module.exports = function (sequelize, DataTypes) { var id = LZString.decompressFromBase64(noteId) if (id && Note.checkNoteIdValid(id)) { return callback(null, id) } else { return _callback(null, null) } } catch (err) { - logger.error(err) + if (err.message === 'Cannot read property \'charAt\' of undefined') { + logger.warning('Looks like we can not decode "' + noteId + '" with LZString. Can be ignored.') + } else { + logger.error(err) + } return _callback(null, null) } }, |