summaryrefslogtreecommitdiff
path: root/src/node/hooks/express
diff options
context:
space:
mode:
authorStefan <stefan@stefans-entwicklerecke.de>2018-02-03 12:57:42 +0100
committerGitHub <noreply@github.com>2018-02-03 12:57:42 +0100
commit89ad3cb809c9069325cebb30f67b887abf582028 (patch)
tree6a7bc87024e315846f8ae66d3da42968d9f9dd13 /src/node/hooks/express
parent32027134cbe4e37ced89091bf05e9fd07980ca12 (diff)
parent1e25e7fc773eb360b2fed52c39c3a14bc2a443ff (diff)
downloadetherpad-lite-master.zip
Merge new release into master branch!HEADmaster
Diffstat (limited to 'src/node/hooks/express')
-rw-r--r--src/node/hooks/express/apicalls.js3
-rw-r--r--src/node/hooks/express/errorhandling.js3
2 files changed, 5 insertions, 1 deletions
diff --git a/src/node/hooks/express/apicalls.js b/src/node/hooks/express/apicalls.js
index db0fc81f..4482fd84 100644
--- a/src/node/hooks/express/apicalls.js
+++ b/src/node/hooks/express/apicalls.js
@@ -3,6 +3,7 @@ var apiLogger = log4js.getLogger("API");
var clientLogger = log4js.getLogger("client");
var formidable = require('formidable');
var apiHandler = require('../../handler/APIHandler');
+var isVarName = require('is-var-name');
//This is for making an api call, collecting all post information and passing it to the apiHandler
var apiCaller = function(req, res, fields) {
@@ -18,7 +19,7 @@ var apiCaller = function(req, res, fields) {
apiLogger.info("RESPONSE, " + req.params.func + ", " + response);
//is this a jsonp call, if yes, add the function call
- if(req.query.jsonp)
+ if(req.query.jsonp && isVarName(response))
response = req.query.jsonp + "(" + response + ")";
res._____send(response);
diff --git a/src/node/hooks/express/errorhandling.js b/src/node/hooks/express/errorhandling.js
index 7afe80ae..c36595bd 100644
--- a/src/node/hooks/express/errorhandling.js
+++ b/src/node/hooks/express/errorhandling.js
@@ -49,5 +49,8 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//sigint is so far not working on windows
//https://github.com/joyent/node/issues/1553
process.on('SIGINT', exports.gracefulShutdown);
+ // when running as PID1 (e.g. in docker container)
+ // allow graceful shutdown on SIGTERM c.f. #3265
+ process.on('SIGTERM', exports.gracefulShutdown);
}
}