mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
fix export of bad pads and also limit import to files
This commit is contained in:
parent
abb9b6d833
commit
d5bec1701e
2 changed files with 17 additions and 2 deletions
|
@ -48,7 +48,7 @@ exports.getPadRaw = function(padId, callback){
|
||||||
|
|
||||||
// Get the author info
|
// Get the author info
|
||||||
db.get("globalAuthor:"+authorId, function(e, authorEntry){
|
db.get("globalAuthor:"+authorId, function(e, authorEntry){
|
||||||
authorEntry.padIDs = padId;
|
if(authorEntry && authorEntry.padIDs) authorEntry.padIDs = padId;
|
||||||
if(!e) data["globalAuthor:"+authorId] = authorEntry;
|
if(!e) data["globalAuthor:"+authorId] = authorEntry;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,22 @@ var db = require("../db/DB").db;
|
||||||
exports.setPadRaw = function(padId, records, callback){
|
exports.setPadRaw = function(padId, records, callback){
|
||||||
records = JSON.parse(records);
|
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){
|
async.eachSeries(Object.keys(records), function(key, cb){
|
||||||
var value = records[key]
|
var value = records[key]
|
||||||
|
|
||||||
|
if(!value){
|
||||||
|
cb(); // null values are bad.
|
||||||
|
}
|
||||||
|
|
||||||
// Author data
|
// Author data
|
||||||
if(value.padIDs){
|
if(value.padIDs){
|
||||||
// rewrite author pad ids
|
// rewrite author pad ids
|
||||||
|
@ -34,7 +47,9 @@ exports.setPadRaw = function(padId, records, callback){
|
||||||
db.get(key, function(err, author){
|
db.get(key, function(err, author){
|
||||||
if(author){
|
if(author){
|
||||||
// Yes, add the padID to the 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;
|
value = author;
|
||||||
}else{
|
}else{
|
||||||
// No, create a new array with the author info in
|
// No, create a new array with the author info in
|
||||||
|
|
Loading…
Reference in a new issue