Commit 0cae5d0
committed
fix: send author-attributed inserts and preserve trailing newline
Etherpad's USER_CHANGES handler now (post-2.7.x, see ether/etherpad#7773)
rejects two kinds of malformed inserts:
1. `+` ops with no `author` attribute — they grow pad.atext.text without
contributing matching markers to pad.atext.attribs, leaving the two
iterables out of sync and breaking setDocAText reconciliation on
every later client load.
2. USER_CHANGES whose application would leave the pad text not ending
with '\n' — the browser's line assembler asserts on docs that don't
end with '\n' and the session dies.
Both were silently produced by `ee.append()`: it called
`makeSplice(text, text.length, 0, ins)` (insert at very end, no attribs,
no pool). When the host pad starts as `'\n'`, appending `'1'` produced
`'\n1'` (no trailing newline) and the changeset's insert carried no
author attribute.
Fix:
* Capture `userId` from CLIENT_VARS and use it as the author attribute
on subsequent inserts.
* Splice at `text.length - 1` so the insert lands before the trailing
'\n' and the invariant holds.
* Build the changeset against `padState.apool`, then `moveOpsToNewPool`
into a fresh wire apool so the server can resolve the `*N` slot
numbers we send.
Backward-compatible: pre-hardening Etherpad servers accept the new
shape too (it's the same shape the standard JS web client sends).
Refs ether/etherpad#77731 parent 592fa8c commit 0cae5d0
2 files changed
Lines changed: 24 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| 203 | + | |
201 | 204 | | |
202 | 205 | | |
203 | 206 | | |
| |||
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
243 | | - | |
244 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
245 | 257 | | |
246 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
247 | 265 | | |
248 | 266 | | |
249 | 267 | | |
250 | 268 | | |
251 | | - | |
252 | | - | |
| 269 | + | |
| 270 | + | |
253 | 271 | | |
254 | 272 | | |
255 | 273 | | |
| |||
0 commit comments