Skip to content

Consolidate header field-pair validation into fields::is_field_valid#2506

Merged
yhirose merged 1 commit into
masterfrom
refactor/consolidate-field-validation
Jul 23, 2026
Merged

Consolidate header field-pair validation into fields::is_field_valid#2506
yhirose merged 1 commit into
masterfrom
refactor/consolidate-field-validation

Conversation

@yhirose

@yhirose yhirose commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

The is_field_name(name) && is_field_value(value) predicate — the guard against CR/LF injection / response splitting — had accumulated in five separate output paths:

The most recent addition (#2505) was a near-verbatim copy of the chunked-trailer skip block. This consolidates the shared predicate into a single fields::is_field_valid(name, value) helper and routes all five sites through it.

Notes

  • No behavior change. Each site keeps its own follow-up action (emplace / continue / return false / set Error::InvalidHeaders); only the duplicated predicate is centralized.
  • Follows the existing header-only split convention: forward declaration in the fields declaration block, inline definition in the implementation area next to is_field_value.
  • Net −5 lines.

Testing

  • make test_split builds clean.
  • Response-splitting, chunked-trailer, WebSocket handshake, header-smuggling, and set_header tests all pass.

The is_field_name(name) && is_field_value(value) predicate was repeated
across five output paths (set_header, write_headers, write_content_chunked
trailer, perform_websocket_handshake, check_and_write_headers). Introduce
fields::is_field_valid(name, value) and route all five through it so the
CR/LF-injection guard has a single definition. No behavior change.
@yhirose
yhirose merged commit cc1be5e into master Jul 23, 2026
59 of 61 checks passed
@yhirose
yhirose deleted the refactor/consolidate-field-validation branch July 24, 2026 00:07
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