Commit 093d639
committed
Fix CWE-190: properly parse RFC 2046 quoted-string boundary values
The previous code stripped all double-quote characters from the boundary
string using a blanket replace(), which would silently corrupt boundary
values that contain escaped quotes (\") and could leave a trailing
semi-colon if the quoted string was followed by another parameter.
Replace with a proper RFC 2045/2046 quoted-string parser:
- Token form (no leading quote): trim and stop at the next ';'.
- Quoted-string form (leading '"'): scan forward for the closing quote,
skipping backslash-escaped quotes (\") along the way; extract the
content between the outer quotes. Reject unterminated quoted strings
(missing closing quote) immediately with PARSE_REQ_FAIL + abort().
This was reviewed and proposed by GitHub Copilot Autofix.1 parent c7114c0 commit 093d639
1 file changed
Lines changed: 36 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
514 | | - | |
515 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
516 | 517 | | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | 518 | | |
523 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
524 | 552 | | |
525 | 553 | | |
526 | 554 | | |
| |||
0 commit comments