From f4418149cb9c34f71f398d6dee4de7845bb103d5 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 7 Apr 2020 01:07:10 +0200 Subject: [PATCH] import: introduce importMaxFileSize setting. Defaults to 50 MB From Etherpad 1.8.3 onwards, the maximum allowed size for a single imported file will always be bounded. The maximum allowed size can be configured via importMaxFileSize. --- settings.json.docker | 8 ++++++++ settings.json.template | 8 ++++++++ src/node/handler/ImportHandler.js | 1 + src/node/utils/Settings.js | 8 ++++++++ 4 files changed, 25 insertions(+) diff --git a/settings.json.docker b/settings.json.docker index b33b0f0e4..56677274f 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -408,6 +408,14 @@ "indentationOnNewLine": false, */ + /* + * From Etherpad 1.8.3 onwards, the maximum allowed size for a single imported + * file is always bounded. + * + * File size is specified in bytes. Default is 50 MB. + */ + "importMaxFileSize": 52428800, // 50 * 1024 * 1024 + /* * Toolbar buttons configuration. * diff --git a/settings.json.template b/settings.json.template index f714f9a21..97ed7844b 100644 --- a/settings.json.template +++ b/settings.json.template @@ -413,6 +413,14 @@ "indentationOnNewLine": false, */ + /* + * From Etherpad 1.8.3 onwards, the maximum allowed size for a single imported + * file is always bounded. + * + * File size is specified in bytes. Default is 50 MB. + */ + "importMaxFileSize": 52428800, // 50 * 1024 * 1024 + /* * Toolbar buttons configuration. * diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index 02ef92635..e3bdcb1c6 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -72,6 +72,7 @@ async function doImport(req, res, padId) let form = new formidable.IncomingForm(); form.keepExtensions = true; form.uploadDir = tmpDirectory; + form.maxFileSize = settings.importMaxFileSize; // locally wrapped Promise, since form.parse requires a callback let srcFile = await new Promise((resolve, reject) => { diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 2d519d0ab..4c808620b 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -305,6 +305,14 @@ exports.scrollWhenFocusLineIsOutOfViewport = { */ exports.exposeVersion = false; +/* + * From Etherpad 1.8.3 onwards, the maximum allowed size for a single imported + * file is always bounded. + * + * File size is specified in bytes. Default is 50 MB. + */ +exports.importMaxFileSize = 50 * 1024 * 1024; + // checks if abiword is avaiable exports.abiwordAvailable = function() {