First pass at encoding changes & comments in ranges

This commit is contained in:
Alasdair Smith 2017-09-21 13:25:55 +01:00
parent 72ef354206
commit 9f503f1e9f

View file

@ -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