laminas / laminas-diactoros

PSR HTTP Message implementations
https://docs.laminas.dev/laminas-diactoros/
BSD 3-Clause "New" or "Revised" License
483 stars 63 forks source link

Filter integer header names during SAPI discovery #157

Closed weierophinney closed 1 year ago

weierophinney commented 1 year ago
Q A
Documentation yes
Bugfix yes
BC Break yes
New Feature no
RFC no
QA no

Description

Integer strings have the nasty habit of being cast to actual integers by PHP, making them problematic for usage in an associative array, despite being valid per the RFC 7230 ABNF.

Additionally, having them pass through marshal_headers_from_sapi() means that once ServerRequest gets them and tries to use them, HeaderSecurity::assertValidName() will raise an exception for integers, which could lead to unexpected server errors.

This patch chooses to filter such header names out entirely. It also documents the change, and ways to address it if you previously depended on integer header field names.

Fixes #11