From 9f503f1e9f857d90a06d53122c2ba20cb6388375 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 21 Sep 2017 13:25:55 +0100 Subject: [PATCH] First pass at encoding changes & comments in ranges --- .../app/coffee/WebsocketController.coffee | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/services/real-time/app/coffee/WebsocketController.coffee b/services/real-time/app/coffee/WebsocketController.coffee index e0242d4208..e4057baf7c 100644 --- a/services/real-time/app/coffee/WebsocketController.coffee +++ b/services/real-time/app/coffee/WebsocketController.coffee @@ -101,6 +101,30 @@ module.exports = WebsocketController = logger.err {err, project_id, doc_id, fromVersion, line, client_id: client.id}, "error encoding line uri component" return callback(err) escapedLines.push line + + if ranges.comments + escapedComments = [] + for comment in ranges.comments + try + comment.op.c = unescape(encodeURIComponent(comment.op.c)) + catch err + logger.err {err, project_id, doc_id, fromVersion, comment, client_id: client.id}, "error encoding comment uri component" + return callback(err) + escapedComments.push comment + ranges.comments = escapedComments + + if ranges.changes + escapedChanges = [] + for change in ranges.changes + try + change.op.i = unescape(encodeURIComponent(change.op.i)) if change.op.i + change.op.d = unescape(encodeURIComponent(change.op.d)) if change.op.d + catch err + logger.err {err, project_id, doc_id, fromVersion, change, client_id: client.id}, "error encoding change uri component" + return callback(err) + escapedChanges.push change + ranges.changes = escapedChanges + AuthorizationManager.addAccessToDoc client, doc_id client.join(doc_id) callback null, escapedLines, version, ops, ranges