summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/config/default.js3
-rw-r--r--lib/config/index.js2
-rw-r--r--lib/response.js14
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/config/default.js b/lib/config/default.js
index 6096bce4..c34279bd 100644
--- a/lib/config/default.js
+++ b/lib/config/default.js
@@ -104,7 +104,8 @@ module.exports = {
baseURL: undefined,
clientID: undefined,
clientSecret: undefined,
- scope: undefined
+ scope: undefined,
+ version: 'v4'
},
mattermost: {
baseURL: undefined,
diff --git a/lib/config/index.js b/lib/config/index.js
index f96684ea..26f0ae96 100644
--- a/lib/config/index.js
+++ b/lib/config/index.js
@@ -104,7 +104,7 @@ config.isOAuth2Enable = config.oauth2.clientID && config.oauth2.clientSecret
config.isPDFExportEnable = config.allowPDFExport
// Check gitlab api version
-if (config.gitlab.version !== 'v4' && config.gitlab.version !== 'v3') {
+if (config.gitlab && config.gitlab.version !== 'v4' && config.gitlab.version !== 'v3') {
logger.warn('config.js contains wrong version (' + config.gitlab.version + ') for gitlab api; it should be \'v3\' or \'v4\'. Defaulting to v4')
config.gitlab.version = 'v4'
}
diff --git a/lib/response.js b/lib/response.js
index 37211998..4df036b7 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -32,6 +32,9 @@ var response = {
errorBadRequest: function (res) {
responseError(res, '400', 'Bad Request', 'something not right.')
},
+ errorTooLong: function (res) {
+ responseError(res, '413', 'Payload Too Large', 'Shorten your note!')
+ },
errorInternalError: function (res) {
responseError(res, '500', 'Internal Error', 'wtf.')
},
@@ -145,7 +148,12 @@ function responseCodiMD (res, note) {
function newNote (req, res, next) {
var owner = null
- var body = req.body ? req.body : ''
+ var body = ''
+ if (req.body && req.body.length > config.documentMaxLength) {
+ return response.errorTooLong(res)
+ } else if (req.body) {
+ body = req.body
+ }
body = body.replace(/[\r]/g, '')
if (req.isAuthenticated()) {
owner = req.user.id
@@ -341,6 +349,10 @@ function actionPDF (req, res, note) {
var path = config.tmpPath + '/' + Date.now() + '.pdf'
content = content.replace(/\]\(\//g, '](' + url + '/')
markdownpdf().from.string(content).to(path, function () {
+ if (!fs.existsSync(path)) {
+ logger.error('PDF seems to not be generated as expected. File doesn\'t exist: ' + path)
+ return response.errorInternalError(res)
+ }
var stream = fs.createReadStream(path)
var filename = title
// Be careful of special characters