diff options
author | Marcel Klehr <mklehr@gmx.net> | 2013-10-10 16:38:41 +0200 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2013-10-10 16:38:41 +0200 |
commit | 6689a3c02e8c25ef30832f27b6647627f3f97d12 (patch) | |
tree | 8361056c7a12153292dfa6399ce637c009170500 /src | |
parent | ccf4683558928925ec2f637be05916e8f1a2e91e (diff) | |
download | etherpad-lite-6689a3c02e8c25ef30832f27b6647627f3f97d12.zip |
Catch errors during preparation of client vars
... and disconnect the user
Diffstat (limited to 'src')
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 4adf6002..0bdc402f 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1006,11 +1006,17 @@ function handleClientReady(client, message) //This is a normal first connect else { - //prepare all values for the wire - var atext = Changeset.cloneAText(pad.atext); - var attribsForWire = Changeset.prepareForWire(atext.attribs, pad.pool); - var apool = attribsForWire.pool.toJsonable(); - atext.attribs = attribsForWire.translated; + //prepare all values for the wire, there'S a chance that this throws, if the pad is corrupted + try { + var atext = Changeset.cloneAText(pad.atext); + var attribsForWire = Changeset.prepareForWire(atext.attribs, pad.pool); + var apool = attribsForWire.pool.toJsonable(); + atext.attribs = attribsForWire.translated; + }catch(e) { + console.error(e.stack || e) + client.json.send({disconnect:"padCorrupted"});// pull the breaks + return callback(); + } // Warning: never ever send padIds.padId to the client. If the // client is read only you would open a security hole 1 swedish |