Skip to content

Commit

Permalink
Merge pull request #2203 from ether/setting-to-not-import-unknown-fil…
Browse files Browse the repository at this point in the history
…e-types

Allow for a setting so you can stop unknown file types from being imported
  • Loading branch information
JohnMcLear committed Nov 15, 2014
2 parents f5fbcbb + 83b7ca5 commit 3bf108f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
11 changes: 7 additions & 4 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,22 @@
/* This is the path to the Abiword executable. Setting it to null, disables abiword.
Abiword is needed to advanced import/export features of pads*/
"abiword" : null,

/* Allow import of file types other than the supported types: txt, doc, docx, rtf, odt, html & htm */
"allowUnknownFileEnds" : true,

/* This setting is used if you require authentication of all users.
Note: /admin always requires authentication. */
"requireAuthentication": false,
"requireAuthentication" : false,

/* Require authorization by a module, or a user with is_admin set, see below. */
"requireAuthorization": false,
"requireAuthorization" : false,

/*when you use NginX or another proxy/ load-balancer set this to true*/
"trustProxy": false,
"trustProxy" : false,

/* Privacy: disable IP logging */
"disableIPlogging": false,
"disableIPlogging" : false,

/* Users for basic authentication. is_admin = true gives access to /admin.
If you do not uncomment this, /admin will not be available! */
Expand Down
11 changes: 8 additions & 3 deletions src/node/handler/ImportHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ exports.doImport = function(req, res, padId)
}
//we need to rename this file with a .txt ending
else {
var oldSrcFile = srcFile;
srcFile = path.join(path.dirname(srcFile),path.basename(srcFile, fileEnding)+".txt");
fs.rename(oldSrcFile, srcFile, callback);
if(settings.allowUnknownFileEnds === true){
var oldSrcFile = srcFile;
srcFile = path.join(path.dirname(srcFile),path.basename(srcFile, fileEnding)+".txt");
fs.rename(oldSrcFile, srcFile, callback);
}else{
console.warn("Not allowing unknown file type to be imported", fileEnding);
callback("uploadFailed");
}
}
},
function(callback){
Expand Down
5 changes: 5 additions & 0 deletions src/node/utils/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ exports.minify = true;
*/
exports.abiword = null;

/**
* Should we support none natively supported file types on import?
*/
exports.allowUnknownFileEnds = true;

/**
* The log level of log4js
*/
Expand Down

0 comments on commit 3bf108f

Please sign in to comment.