Commit 7807c8d
numfmt: do not panic on a multibyte whitespace field separator
write_formatted_with_whitespace normalized the delimiter before the
second and subsequent selected fields by writing a single space and
dropping the first byte of the leading whitespace run with `&prefix[1..]`.
That assumed an ASCII separator: WhitespaceSplitter splits on Unicode
`char::is_whitespace`, so a multibyte separator (e.g. U+3000 IDEOGRAPHIC
SPACE) made `&prefix[1..]` slice inside the character and abort with a
char-boundary panic.
Drop the first character instead of the first byte, using its UTF-8
length, so the slice always lands on a char boundary.1 parent 93fa095 commit 7807c8d
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
848 | | - | |
| 848 | + | |
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
434 | 444 | | |
435 | 445 | | |
436 | 446 | | |
| |||
0 commit comments