Pita/etherpad-lite — Issue #262: Changset.splitAttributionLines assumes a new line at the end of the string when there are new lines in the op
Author: pdobrev
Created: 2011-12-02 08:56:48+00:00
State: open

https://github.com/Pita/etherpad-lite/blob/master/node/utils/Changeset.js#L1166

splitAttributionLines assumes that if there's one new line in a given op, it will be at the end of the string and will add it as a separate attribution line.

For example, if you have the following op in a changeset:
Line1\n*some text*

it will get pushed as one attribution line, instead of adding Line1 as one line and *some text* to the next.

I am not sure if you can have this scenario is regular etherpad usage, probably not. I was using etherpad changesets and it's exportHtml functionality for a project of mine, when I bumped into this issue.

Changing the if block to the following fixed it for me:

if (numLines == 1) {
var newlineEnd = text.indexOf('\n', pos) + 1;
if (newlineEnd != pos + numChars) {
// newline not at the end
op.chars = newlineEnd - pos;
op.lines = 1;
appendOp(op);
numChars -= op.chars;

op.chars = numChars;
op.lines = 0;
} else {
op.chars = numChars;
op.lines = 1;
}
}