diff options
author | Marcel Klehr <mklehr@gmx.net> | 2013-10-10 18:19:25 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2013-10-10 18:19:25 +0200 |
commit | d4c99d40b832a0742de0f466ef30f7c680888dcf (patch) | |
tree | 80a382e1297d768b305c958179014c4244f11a10 /src | |
parent | 6689a3c02e8c25ef30832f27b6647627f3f97d12 (diff) | |
download | etherpad-lite-d4c99d40b832a0742de0f466ef30f7c680888dcf.zip |
Never keep processing a changeset if it's corrupted
Diffstat (limited to 'src')
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 0bdc402f..e96f64eb 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -594,7 +594,7 @@ function handleUserChanges(data, cb) // defined in the accompanying attribute pool. Changeset.eachAttribNumber(changeset, function(n) { if (! wireApool.getAttrib(n)) { - throw "Attribute pool is missing attribute "+n+" for changeset "+changeset; + throw new Error("Attribute pool is missing attribute "+n+" for changeset "+changeset); } }); @@ -608,23 +608,22 @@ function handleUserChanges(data, cb) if(!attr) return attr = wireApool.getAttrib(attr) if(!attr) return - if('author' == attr[0] && attr[1] != thisSession.author) throw "Trying to submit changes as another author" + if('author' == attr[0] && attr[1] != thisSession.author) throw new Error("Trying to submit changes as another author in changeset "+changeset); }) } + + //ex. adoptChangesetAttribs + + //Afaik, it copies the new attributes from the changeset, to the global Attribute Pool + changeset = Changeset.moveOpsToNewPool(changeset, wireApool, pad.pool); } catch(e) { // There is an error in this changeset, so just refuse it - console.warn("Can't apply USER_CHANGES "+changeset+", because: "+e); client.json.send({disconnect:"badChangeset"}); - return callback(); + return callback(new Error("Can't apply USER_CHANGES, because "+e.message)); } - //ex. adoptChangesetAttribs - - //Afaik, it copies the new attributes from the changeset, to the global Attribute Pool - changeset = Changeset.moveOpsToNewPool(changeset, wireApool, pad.pool); - //ex. applyUserChanges apool = pad.pool; r = baseRev; @@ -651,9 +650,8 @@ function handleUserChanges(data, cb) { changeset = Changeset.follow(c, changeset, false, apool); }catch(e){ - console.warn("Can't apply USER_CHANGES "+changeset+", possibly because of mismatched follow error"); client.json.send({disconnect:"badChangeset"}); - return callback(); + return callback(new Error("Can't apply USER_CHANGES, because "+e.message)); } if ((r - baseRev) % 200 == 0) { // don't let the stack get too deep @@ -674,9 +672,8 @@ function handleUserChanges(data, cb) if (Changeset.oldLen(changeset) != prevText.length) { - console.warn("Can't apply USER_CHANGES "+changeset+" with oldLen " + Changeset.oldLen(changeset) + " to document of length " + prevText.length); client.json.send({disconnect:"badChangeset"}); - return callback(); + return callback(new Error("Can't apply USER_CHANGES "+changeset+" with oldLen " + Changeset.oldLen(changeset) + " to document of length " + prevText.length)); } pad.appendRevision(changeset, thisSession.author); @@ -700,7 +697,7 @@ function handleUserChanges(data, cb) ], function(err) { cb(); - ERR(err); + if(err) console.warn(err.stack || err) }); } |