Merge pull request #1750 from ether/fix/authorship-once-and-4-all
Fix authorship sanitization
This commit is contained in:
commit
f478f99995
|
@ -163,12 +163,12 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
{
|
{
|
||||||
// Get my authorID
|
// Get my authorID
|
||||||
var authorId = parent.parent.pad.myUserInfo.userId;
|
var authorId = parent.parent.pad.myUserInfo.userId;
|
||||||
// Rewrite apool authors with my author information
|
|
||||||
|
|
||||||
// We need to replace all new author attribs with thisSession.author, in case someone copy/pasted or otherwise inserted other peoples changes
|
// Sanitize authorship
|
||||||
|
// We need to replace all author attribs with thisSession.author, in case they copy/pasted or otherwise inserted other peoples changes
|
||||||
if(apool.numToAttrib){
|
if(apool.numToAttrib){
|
||||||
for (var attr in apool.numToAttrib){
|
for (var attr in apool.numToAttrib){
|
||||||
if (apool.numToAttrib[attr][0] == 'author' && apool.numToAttrib[attr][1] == authorId) authorAttr = attr
|
if (apool.numToAttrib[attr][0] == 'author' && apool.numToAttrib[attr][1] == authorId) authorAttr = Number(attr).toString(36)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace all added 'author' attribs with the value of the current user
|
// Replace all added 'author' attribs with the value of the current user
|
||||||
|
@ -176,6 +176,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
, iterator = Changeset.opIterator(cs.ops)
|
, iterator = Changeset.opIterator(cs.ops)
|
||||||
, op
|
, op
|
||||||
, assem = Changeset.mergingOpAssembler();
|
, assem = Changeset.mergingOpAssembler();
|
||||||
|
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
op = iterator.next()
|
op = iterator.next()
|
||||||
if(op.opcode == '+') {
|
if(op.opcode == '+') {
|
||||||
|
@ -183,13 +184,13 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
|
|
||||||
op.attribs.split('*').forEach(function(attrNum) {
|
op.attribs.split('*').forEach(function(attrNum) {
|
||||||
if(!attrNum) return
|
if(!attrNum) return
|
||||||
attr = apool.getAttrib(attrNum)
|
var attr = apool.getAttrib(parseInt(attrNum, 36))
|
||||||
if(!attr) return
|
if(!attr) return
|
||||||
if('author' == attr[0] && !~newAttrs.indexOf(authorAttr)) {
|
if('author' == attr[0]) {
|
||||||
|
// replace that author with the current one
|
||||||
newAttrs += '*'+authorAttr;
|
newAttrs += '*'+authorAttr;
|
||||||
// console.log('replacing author attribute ', attrNum, '(', attr[1], ') with', authorAttr)
|
|
||||||
}
|
}
|
||||||
else newAttrs += '*'+attrNum
|
else newAttrs += '*'+attrNum // overtake all other attribs as is
|
||||||
})
|
})
|
||||||
op.attribs = newAttrs
|
op.attribs = newAttrs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue