Repository navigation
Commit 0a40d3f
committed
shared: return None (not ValueError) for a non-ASCII base64 header
decode_header_value only caught binascii.Error, but base64.b64decode raises a
plain ValueError for a non-ASCII payload ("string argument should contain only
ASCII characters"). A raw Mcp-Name like `=?base64?\xe9?=` therefore escaped the
modern POST handler and turned into a 500 instead of the HEADER_MISMATCH
rejection the docstring promises. Same for Mcp-Param-* headers, which go
through the same function.
Catching ValueError covers both cases since binascii.Error subclasses it.
Checked with a small ASGI repro: the high-byte header now answers 400 /
-32020 like every other undecodable sentinel, and the fuzzer-shaped input no
longer reaches the server's error path.
Fixes #38171 parent af4c6f4 commit 0a40d3f
3 files changed
Lines changed: 32 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
447 | 465 | | |
448 | 466 | | |
449 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
426 | 435 | | |
427 | 436 | | |
428 | 437 | | |
| |||
0 commit comments