From de552df6db435717912bad3aad558d343c23d8f8 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Fri, 15 Mar 2013 18:08:51 +0100 Subject: [PATCH] Fix clearing authorship colors which was broken by #1609 Fixes #1620 --- src/node/handler/PadMessageHandler.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 35f1ab4cc..4b98292ec 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -551,10 +551,19 @@ function handleUserChanges(client, message) } }); - // Validate all 'author' attribs to be the same value as the current user - wireApool.eachAttrib(function(type, value) { - if('author' == type && value != thisSession.author) throw "Trying to submit changes as another author" - }) + // Validate all added 'author' attribs to be the same value as the current user + var iterator = Changeset.opIterator(Changeset.unpack(changeset).ops) + , op + while(iterator.hasNext()) { + op = iterator.next() + if(op.opcode != '+') continue; + op.attribs.split('*').forEach(function(attr) { + 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" + }) + } } catch(e) {