Skip to content

fix: route lenient bare-LF request version to headers_start - #927

Open
zsh20070718 wants to merge 1 commit into
nodejs:mainfrom
zsh20070718:fix/lenient-bare-lf-request-version
Open

zsh20070718 wants to merge 1 commit into
nodejs:mainfrom
zsh20070718:fix/lenient-bare-lf-request-version

Conversation

@zsh20070718

Copy link
Copy Markdown

req_http_complete already consumes \n via .match('\n', ...) before checking LENIENT_OPTIONAL_CR_BEFORE_LF (checkIfAllowLFWithoutCR). Previously, the allowed branch transitioned to req_http_complete_crlf, which expects another \n (unless OPTIONAL_LF_AFTER_CR is also enabled). As a result, a request line ending with a bare \n under LENIENT_OPTIONAL_CR_BEFORE_LF alone failed with Expected CRLF after version (ERROR.STRICT) instead of entering header parsing.

This routes req_http_complete's bare-\n checkIfAllowLFWithoutCR success branch directly to headers_start, matching the response status (onStatusComplete, bypassing res_line_almost_done) and HTTP/0.9 (toHTTP09BareLF -> toHTTP09 -> headers_start) bare-LF paths.

Changes

  • src/llhttp/http.ts: transition req_http_complete directly to headers_start when LENIENT_OPTIONAL_CR_BEFORE_LF allows a bare \n.
  • test/request/sample.md: add a request-lenient-optional-cr-before-lf test case (GET / HTTP/1.1\nHost: foo\r\n\r\n).

Verification

  • Verified cleanly against 2c4ac10 with git apply --check and traced the parser state transitions and byte offsets in src/llhttp/http.ts (off=14 version complete, off=15 start of Host header).
  • tsx is unavailable in this local environment, so npm test could not run here; relying on CI to run the full test suite.

This branch has not been deployed

No deployments
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