Merge pull request #1909 from ether/dont-crash-blank-html-import

dont crash on importing blank html
This commit is contained in:
John McLear 2013-09-27 12:06:05 -07:00
commit e573461c9b
1 changed files with 10 additions and 2 deletions

View File

@ -28,7 +28,9 @@ var ERR = require("async-stacktrace")
, settings = require('../utils/Settings')
, formidable = require('formidable')
, os = require("os")
, importHtml = require("../utils/ImportHtml");
, importHtml = require("../utils/ImportHtml")
, log4js = require('log4js');
//load abiword only if its enabled
if(settings.abiword != null)
@ -42,6 +44,8 @@ var tmpDirectory = process.env.TEMP || process.env.TMPDIR || process.env.TMP ||
*/
exports.doImport = function(req, res, padId)
{
var apiLogger = log4js.getLogger("ImportHandler");
//pipe to a file
//convert file to html via abiword
//set html in the pad
@ -169,7 +173,11 @@ exports.doImport = function(req, res, padId)
function(callback) {
var fileEnding = path.extname(srcFile).toLowerCase();
if (abiword || fileEnding == ".htm" || fileEnding == ".html") {
importHtml.setPadHTML(pad, text);
try{
importHtml.setPadHTML(pad, text);
}catch(e){
apiLogger.warn("Error importing, possibly caused by malformed HTML");
}
} else {
pad.setText(text);
}