Skip to content

Require tiny-blocks/http 8.0 and reject malformed mapped headers. - #12

Merged
gustavofreze merged 4 commits into
mainfrom
fix/header-pattern-end-anchor
Nov 7, 2026
Merged

gustavofreze merged 4 commits into
mainfrom
fix/header-pattern-end-anchor

Conversation

@gustavofreze

@gustavofreze gustavofreze commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Please follow the contributing guidelines.

Summary

  • MappedError rejects a header whose name or value ends in a line feed with HttpHeaderMalformed. The NAME and VALUE patterns of ResponseHeaders ended in $ without the D modifier, and $ matches before a final \n, so "Retry-After\n" and "60\n" passed.
  • Both patterns now carry D, and two tests cover the trailing line feed on the name and on the value.
  • composer.json requires tiny-blocks/http ^8.0 (was ^7.2). 8.0 validates every header that reaches a response and rejects the connection-specific ones (tiny-blocks/http#74).
  • MappedError also rejects a connection-specific header (Connection, Keep-Alive, Proxy-Connection, Transfer-Encoding, Upgrade, and TE with any value other than trailers, names case-insensitive) with HttpHeaderMalformed. Under 8.0 a rule declaring one would have made withHeader() throw HeaderIsConnectionSpecific while the error response was being built, inside the middleware. HTTP/2 and HTTP/3 treat such a response as malformed, so the existing exception fits. The README and the HttpHeaderMalformed docblock document it.

CI

CI resolves tiny-blocks/http ^8.0 from Packagist, so it stays red until tiny-blocks/http 8.0.0 is published. Merge after that release and a green re-run. Locally, make review and make tests pass against the 8.0 branch of tiny-blocks/http installed through a temporary, uncommitted path repository (143 tests, 214 mutants, MSI 100%).

Release

Recommended release: 3.0.0 (major), replacing the 2.0.5 this PR first proposed. The public API exposes tiny-blocks/http types (TinyBlocks\Http\Code in ErrorPayload, ReportedError, ReportingPriority and ErrorMiddlewareBuilder), so raising the required major of that dependency is a breaking change for consumers. Rejecting connection-specific mapped headers is also input that used to pass and now throws.

Related issue

None.

Checklist

  • Tests added or updated.
  • Documentation updated when applicable.
  • make review passes.
  • make tests passes.

tiny-blocks/http 8.0 refuses Connection, Keep-Alive, Proxy-Connection,
Transfer-Encoding, Upgrade and a TE other than trailers on a response,
so a rule declaring one would have made the error response itself throw
inside the middleware. MappedError now refuses it with
HttpHeaderMalformed, as HTTP/2 and HTTP/3 treat such a response as
malformed.
@gustavofreze gustavofreze changed the title Reject header names and values that end in a line feed. Require tiny-blocks/http 8.0 and reject malformed mapped headers. Nov 7, 2026
@gustavofreze
gustavofreze merged commit c2a8d75 into main Nov 7, 2026
4 checks passed
@gustavofreze
gustavofreze deleted the fix/header-pattern-end-anchor branch November 7, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant