mirror of
https://github.com/neovim/neovim.git
synced 2026-09-02 20:34:06 +00:00
fix(lsp): blank line before Content-Length breaks header parsing #41524
Problem: A blank line before the Content-Length header makes header parsing fail with "Content-Length not found in header". An LF in the 'name' state falls through to the 'invalid' state, which only return to 'name' at the *next* LF. That LF terminates the next line, so the line with Content-Length is swallowed. The same issue happens when a junk line is a partial match of the header name (e.g. "Cont\nContent-Length: ..."). Solution: When seeing an LF in the 'name' state, reset the cursor and stay in 'name' rather than entering 'invalid'.
This commit is contained in:
@@ -41,7 +41,9 @@ local function get_content_length(ptr, start, len)
|
||||
if c >= 65 and c <= 90 then -- lower case
|
||||
c = c + 32
|
||||
end
|
||||
if (c == 32 or c == 9) and j == 1 then -- luacheck: ignore 542
|
||||
if c == 10 then -- a blank line or a line with a prefix of header
|
||||
j = 1
|
||||
elseif (c == 32 or c == 9) and j == 1 then -- luacheck: ignore 542
|
||||
-- skip OWS for compatibility only
|
||||
elseif c == name:byte(j) then
|
||||
j = j + 1
|
||||
|
||||
Reference in New Issue
Block a user