Commit daf7069
committed
fix: count malformed surrogate pairs as separate U+FFFD replacements in the repair cap
The 4-byte branch of utf8BytesExceed skipped the next code unit whenever it
existed, without checking it is a low surrogate — so a run of high surrogates
was counted at 2 bytes per unit while TextEncoder emits 3. The pair path now
requires the next unit in 0xDC00..0xDFFF; anything else counts 3 bytes without
skipping. Regression: 200k high-surrogate pairs (400k code units, 1.2 MB on
the wire) decline repair instead of being admitted at 800k counted bytes.1 parent d8b707e commit daf7069
2 files changed
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
193 | 205 | | |
0 commit comments