diff options
author | John McLear <john@mclear.co.uk> | 2015-02-21 12:33:30 +0000 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2015-02-21 12:33:30 +0000 |
commit | d5bec1701e10c2d0b5f1ffa96fd5ce4e86728e88 (patch) | |
tree | 2ab6448117279dede31f542bfda377cba7d0e5ec /src/node/utils | |
parent | abb9b6d8330c22f10d55931690004a4fb4d1e6e1 (diff) | |
download | etherpad-lite-d5bec1701e10c2d0b5f1ffa96fd5ce4e86728e88.zip |
fix export of bad pads and also limit import to files
Diffstat (limited to 'src/node/utils')
-rw-r--r-- | src/node/utils/ExportEtherpad.js | 2 | ||||
-rw-r--r-- | src/node/utils/ImportEtherpad.js | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/node/utils/ExportEtherpad.js b/src/node/utils/ExportEtherpad.js index 4f91e4e3..b7d43852 100644 --- a/src/node/utils/ExportEtherpad.js +++ b/src/node/utils/ExportEtherpad.js @@ -48,7 +48,7 @@ exports.getPadRaw = function(padId, callback){ // Get the author info db.get("globalAuthor:"+authorId, function(e, authorEntry){ - authorEntry.padIDs = padId; + if(authorEntry && authorEntry.padIDs) authorEntry.padIDs = padId; if(!e) data["globalAuthor:"+authorId] = authorEntry; }); diff --git a/src/node/utils/ImportEtherpad.js b/src/node/utils/ImportEtherpad.js index 1574a3a9..37863bff 100644 --- a/src/node/utils/ImportEtherpad.js +++ b/src/node/utils/ImportEtherpad.js @@ -21,9 +21,22 @@ var db = require("../db/DB").db; exports.setPadRaw = function(padId, records, callback){ records = JSON.parse(records); + // !! HACK !! + // If you have a really large pad it will cause a Maximum Range Stack crash + // This is a temporary patch for that so things are kept stable. + var recordCount = Object.keys(records).length; + if(recordCount >= 50000){ + console.warn("Etherpad file is too large to import.. We need to fix this. See https://github.com/ether/etherpad-lite/issues/2524"); + return callback("tooLarge", false); + } + async.eachSeries(Object.keys(records), function(key, cb){ var value = records[key] + if(!value){ + cb(); // null values are bad. + } + // Author data if(value.padIDs){ // rewrite author pad ids @@ -34,7 +47,9 @@ exports.setPadRaw = function(padId, records, callback){ db.get(key, function(err, author){ if(author){ // Yes, add the padID to the author.. - author.padIDs.push(padId); + if( Object.prototype.toString.call(author) === '[object Array]'){ + author.padIDs.push(padId); + } value = author; }else{ // No, create a new array with the author info in |