Commit bd2277f
committed
fix: guard special-token stripping with leak detection
Codex review feedback: sanitizeUserFacingText strips model tokens
from ALL text, which could mangle normal assistant explanations.
Now stripSpecialMarkupFromText only applies MODEL_SPECIAL_TOKEN_RE
when the text actually contains matching control tokens. Also reset
lastIndex after .test() since the regex uses /g flag.
FINAL_TAG_RE still runs unconditionally since <final> tags are
never valid user-facing content.1 parent 52ac357 commit bd2277f
1 file changed
+22
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
407 | 418 | | |
408 | 419 | | |
409 | 420 | | |
410 | 421 | | |
411 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
412 | 433 | | |
413 | 434 | | |
414 | 435 | | |
| |||
0 commit comments