summaryrefslogtreecommitdiff
path: root/src/node/handler/ImportHandler.js
diff options
context:
space:
mode:
authorGared <mu.stefan@googlemail.com>2013-09-10 21:58:28 +0200
committerGared <mu.stefan@googlemail.com>2013-09-10 21:58:28 +0200
commitb336e3863737af078259e40dd1502e8a3083fa8f (patch)
tree4a1ccfc040b0565eed039c9baef2055db3a8ca03 /src/node/handler/ImportHandler.js
parentc08a4dd01f2daa81c62b3666abe6fba1efe76405 (diff)
downloadetherpad-lite-b336e3863737af078259e40dd1502e8a3083fa8f.zip
Add check if uploaded file only contains ascii chars when abiword disabled
Diffstat (limited to 'src/node/handler/ImportHandler.js')
-rw-r--r--src/node/handler/ImportHandler.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js
index a155f5c6..281a8d7b 100644
--- a/src/node/handler/ImportHandler.js
+++ b/src/node/handler/ImportHandler.js
@@ -113,6 +113,30 @@ exports.doImport = function(req, res, padId)
}
},
+ function(callback) {
+ if (!abiword) {
+ // Read the file with no encoding for raw buffer access.
+ fs.readFile(destFile, function(err, buf) {
+ if (err) throw err;
+ var isAscii = true;
+ // Check if there are only ascii chars in the uploaded file
+ for (var i=0, len=buf.length; i<len; i++) {
+ if (buf[i] > 240) {
+ isAscii=false;
+ break;
+ }
+ }
+ if (isAscii) {
+ callback();
+ } else {
+ callback("uploadFailed");
+ }
+ });
+ } else {
+ callback();
+ }
+ },
+
//get the pad object
function(callback) {
padManager.getPad(padId, function(err, _pad){