Commit a9d9848
committed
fix: decode body as UTF-8 explicitly to reject UTF-16/32 JSON
json.loads() auto-detects UTF-8/16/32 per RFC 4627 sec. 3, so a POST
body that is valid JSON when read as UTF-16 or UTF-32 was parsed and
accepted even though the MCP spec requires UTF-8. Decoding the body
explicitly before parsing closes that gap; UnicodeDecodeError still
subclasses ValueError, so it's caught by the existing parse-error
branch and reported as HTTP 400 PARSE_ERROR.
Parameterizes the regression test across cp1252, utf-16, and utf-32.
Reported-by: iamroylim1 parent ce91e6f commit a9d9848
2 files changed
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
494 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
495 | 499 | | |
496 | 500 | | |
497 | 501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
446 | 450 | | |
447 | | - | |
| 451 | + | |
448 | 452 | | |
449 | 453 | | |
450 | | - | |
451 | | - | |
| 454 | + | |
| 455 | + | |
452 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
453 | 461 | | |
454 | 462 | | |
455 | 463 | | |
| |||
474 | 482 | | |
475 | 483 | | |
476 | 484 | | |
477 | | - | |
478 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
479 | 490 | | |
480 | 491 | | |
481 | 492 | | |
| |||
0 commit comments