summaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2014-05-06 21:13:22 +0100
committerJohn McLear <john@mclear.co.uk>2014-05-06 21:13:22 +0100
commit1f7fcd54f14028eb9e596beb75bb5410ce83ca1c (patch)
treee7fe53bd32c90d969105350c186fbf0dc1b094fe /src/node
parente85d09400ea1724cd7b2d510fa328e093bf78620 (diff)
downloadetherpad-lite-1f7fcd54f14028eb9e596beb75bb5410ce83ca1c.zip
working logic for allowing a server side hook to modify the export file name but NOT the extension
Diffstat (limited to 'src/node')
-rw-r--r--src/node/handler/ExportHandler.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js
index 8ff5bc48..b3b6f756 100644
--- a/src/node/handler/ExportHandler.js
+++ b/src/node/handler/ExportHandler.js
@@ -27,6 +27,7 @@ var async = require("async");
var fs = require("fs");
var settings = require('../utils/Settings');
var os = require('os');
+var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
//load abiword only if its enabled
if(settings.abiword != null)
@@ -45,8 +46,13 @@ if(os.type().indexOf("Windows") > -1)
*/
exports.doExport = function(req, res, padId, type)
{
+ // allow fileName to be overwritten by a hook, the type type is kept static for security reasons
+ var fileName = hooks.callAll("exportFileName", padId);
+ // if fileName is not set then set it to the padId, note that fileName is returned as an array.
+ if(!fileName[0]) fileName = padId;
+
//tell the browser that this is a downloadable file
- res.attachment(padId + "." + type);
+ res.attachment(fileName + "." + type);
//if this is a plain text export, we can do this directly
// We have to over engineer this because tabs are stored as attributes and not plain text
@@ -81,7 +87,7 @@ exports.doExport = function(req, res, padId, type)
//ensure html can be collected by the garbage collector
txt = null;
- destFile = tempDirectory + "/eplite_export_" + randNum + "." + type;
+ destFile = tempDirectory + "/etherpad_export_" + randNum + "." + type;
abiword.convertFile(srcFile, destFile, type, callback);
},
//send the file
@@ -168,7 +174,7 @@ exports.doExport = function(req, res, padId, type)
else //write the html export to a file
{
randNum = Math.floor(Math.random()*0xFFFFFFFF);
- srcFile = tempDirectory + "/eplite_export_" + randNum + ".html";
+ srcFile = tempDirectory + "/etherpad_export_" + randNum + ".html";
fs.writeFile(srcFile, html, callback);
}
},
@@ -178,7 +184,7 @@ exports.doExport = function(req, res, padId, type)
//ensure html can be collected by the garbage collector
html = null;
- destFile = tempDirectory + "/eplite_export_" + randNum + "." + type;
+ destFile = tempDirectory + "/etherpad_export_" + randNum + "." + type;
abiword.convertFile(srcFile, destFile, type, callback);
},
//send the file