Commit 66fdbc9
committed
util: strip whole CSI sequences per ECMA-48
stripVTControlCharacters() recognises a control sequence by a hand
written list of final bytes, inherited from the bundled copy of
ansi-regex. The list covers neither parameter bytes such as `<`, used
by mouse reports, nor final bytes such as `@`, `X`, `d`, `a` and `b`,
nor intermediate bytes at all. A sequence that uses one of them matches
only in part, so the rest of it is left in the string rather than
removed.
getStringWidth() strips before measuring and readline places the cursor
from that width, so the leftovers are counted as printable columns.
Add an alternative built from the control sequence structure in
ECMA-48 5.4: CSI, then any number of parameter bytes (0x30-0x3F), then
any number of intermediate bytes (0x20-0x2F), then a single final byte
(0x40-0x7E). Both other alternatives are kept, and the new one carries
its own introducer rather than sharing the existing prefix, because
that prefix also consumes `;` and the two competing for the same run
made the match quadratic.
Eleven cases, every one well formed and in use by terminals today. The
colon sub-parameter form is not among them, since the OSC work already
covers it.
Signed-off-by: Luan Taraschi <130802253+luantaraschi@users.noreply.github.com>1 parent d6e67a5 commit 66fdbc9
2 files changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
289 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
290 | 300 | | |
291 | 301 | | |
292 | 302 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
40 | 61 | | |
41 | 62 | | |
42 | 63 | | |
| |||
0 commit comments