Commit acb9de5
committed
fix(telegram): clip progress text on code-point boundaries to avoid lone surrogates
clipProgressMarkdownText used text.slice(0, MAX - 1), which splits UTF-16
surrogate pairs. When an astral character (e.g. an emoji) straddles the
299/300-code-unit boundary, the slice keeps only the high surrogate half
(\uD83D), producing an invalid character that the Telegram Bot API rejects.
Extract the helper to extensions/telegram/src/truncate.ts as
clipTelegramProgressText and switch to sliceUtf16Safe (from
openclaw/plugin-sdk/text-utility-runtime), mirroring the fix applied to
the equivalent Slack helper in #96382.
Adds truncate.test.ts with five vitest cases covering the straddle,
fits-before-cut, unchanged-short, trimEnd, and ASCII-exact-limit paths.1 parent bea3d29 commit acb9de5
3 files changed
Lines changed: 72 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
367 | | - | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | 370 | | |
378 | 371 | | |
379 | 372 | | |
380 | 373 | | |
381 | 374 | | |
382 | | - | |
| 375 | + | |
383 | 376 | | |
384 | 377 | | |
385 | 378 | | |
| |||
399 | 392 | | |
400 | 393 | | |
401 | 394 | | |
402 | | - | |
| 395 | + | |
403 | 396 | | |
404 | 397 | | |
405 | 398 | | |
| |||
418 | 411 | | |
419 | 412 | | |
420 | 413 | | |
421 | | - | |
| 414 | + | |
422 | 415 | | |
423 | 416 | | |
424 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments