From 01cd82427a4e83e656f084923f8f06a1a61582c9 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Tue, 3 Mar 2015 15:20:33 +0100 Subject: [PATCH 1/5] check author in = operator --- src/node/handler/PadMessageHandler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 7ea5039d8..7521c05c4 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -656,7 +656,12 @@ function handleUserChanges(data, cb) , op while(iterator.hasNext()) { op = iterator.next() - if(op.opcode != '+') continue; + + //+ can add text with attribs + //= can change or add attribs + //- can have attribs, but they are discarded and don't show up in the apool + if(op.opcode == '-') continue; + op.attribs.split('*').forEach(function(attr) { if(!attr) return attr = wireApool.getAttrib(attr) From 0693c0ae970627583f435a0e8a70ab4639b9a2f8 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Tue, 3 Mar 2015 15:37:56 +0100 Subject: [PATCH 2/5] - operator do not show up in the attribs of a pad, but authors could still leak to the pool --- src/node/handler/PadMessageHandler.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 7521c05c4..ab81ad878 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -659,8 +659,7 @@ function handleUserChanges(data, cb) //+ can add text with attribs //= can change or add attribs - //- can have attribs, but they are discarded and don't show up in the apool - if(op.opcode == '-') continue; + //- can have attribs, but they are discarded and don't show up in the attribs - but do show up in the pool op.attribs.split('*').forEach(function(attr) { if(!attr) return From 393a4e54e5517624f07299a436e623a34f8104e2 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Tue, 3 Mar 2015 16:17:39 +0100 Subject: [PATCH 3/5] recognize reconnect in clear_authorship_colors test --- tests/frontend/specs/clear_authorship_colors.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/frontend/specs/clear_authorship_colors.js b/tests/frontend/specs/clear_authorship_colors.js index 5db35612a..41fabe3cf 100644 --- a/tests/frontend/specs/clear_authorship_colors.js +++ b/tests/frontend/specs/clear_authorship_colors.js @@ -47,6 +47,10 @@ describe("clear authorship colors button", function(){ var hasAuthorClass = inner$("div").first().attr("class").indexOf("author") !== -1; expect(hasAuthorClass).to.be(false); + + var disconnectVisible = chrome$("div.disconnected").attr("class").indexOf("visible") === -1 + expect(disconnectVisible).to.be(false); + done(); }); From f249b42ab43c45f255c098c0a9cc904e43b0305a Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Tue, 3 Mar 2015 16:39:14 +0100 Subject: [PATCH 4/5] empty author should be allowed to support clearAuthorship functionality --- src/node/handler/PadMessageHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index ab81ad878..ef8e32b0b 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -665,7 +665,8 @@ function handleUserChanges(data, cb) if(!attr) return attr = wireApool.getAttrib(attr) if(!attr) return - if('author' == attr[0] && attr[1] != thisSession.author) throw new Error("Trying to submit changes as another author in changeset "+changeset); + //the empty author is used in the clearAuthorship functionality so this should be the only exception + if('author' == attr[0] && (attr[1] != thisSession.author && attr[1] != '')) throw new Error("Trying to submit changes as another author in changeset "+changeset); }) } From 547046830e0808b86dcde94b4e8f6da9206ddb89 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Tue, 3 Mar 2015 16:51:18 +0100 Subject: [PATCH 5/5] actually disconnect should NOT be visible... --- tests/frontend/specs/clear_authorship_colors.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/frontend/specs/clear_authorship_colors.js b/tests/frontend/specs/clear_authorship_colors.js index 41fabe3cf..1417f63c6 100644 --- a/tests/frontend/specs/clear_authorship_colors.js +++ b/tests/frontend/specs/clear_authorship_colors.js @@ -47,9 +47,10 @@ describe("clear authorship colors button", function(){ var hasAuthorClass = inner$("div").first().attr("class").indexOf("author") !== -1; expect(hasAuthorClass).to.be(false); - - var disconnectVisible = chrome$("div.disconnected").attr("class").indexOf("visible") === -1 - expect(disconnectVisible).to.be(false); + setTimeout(function(){ + var disconnectVisible = chrome$("div.disconnected").attr("class").indexOf("visible") === -1 + expect(disconnectVisible).to.be(true); + },1000); done(); });