Commit f76da36
committed
Only allow specific trailers
Only allow trailers listed in the `Trailer` header. Even if listed
there, disallow the following names, based on Mozilla
recommendations:
```
content-encoding content-type content-range trailer authorization
set-cookie transfer-encoding content-length host cache-control
max-forwards te
```
There are probably additional ones we should disallow, but this
is a decent start.
Do not merge the header and trailer data. Parse the trailers into
a separate hash, and for allowed names, copy the value into the
headers hash.
This ignores invalid trailers instead of raising an exception,
which is preferable for backwards compatibility.
In order to get the new test to pass, make content_length return
nil instead of of raising a TypeError if no content length was
provided. Also, parse the content length as decimal instead of
trying to autodetect the radix.
Fixes #1981 parent c3aeef0 commit f76da36
2 files changed
Lines changed: 60 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
312 | 314 | | |
313 | 315 | | |
314 | 316 | | |
| |||
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
477 | 484 | | |
478 | 485 | | |
479 | 486 | | |
480 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
481 | 494 | | |
482 | 495 | | |
483 | 496 | | |
| |||
489 | 502 | | |
490 | 503 | | |
491 | 504 | | |
492 | | - | |
| 505 | + | |
493 | 506 | | |
494 | 507 | | |
495 | 508 | | |
496 | | - | |
| 509 | + | |
497 | 510 | | |
498 | | - | |
499 | 511 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
505 | 534 | | |
506 | 535 | | |
507 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
444 | 466 | | |
445 | 467 | | |
446 | 468 | | |
| |||
0 commit comments