Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IndexDefect errors in httpclient on invalid/weird headers #22886

Merged
merged 6 commits into from Nov 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/pure/httpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,9 @@ proc parseResponse(client: HttpClient | AsyncHttpClient,
if line.len == le: httpError("Invalid headers - no colon after header name")
inc(linei, le) # Skip the parsed header name
inc(linei) # Skip :
if linei == line.len: httpError("Invalid headers - no header value after colon")
# Here linei is smaller or equal to line.len, so the slice below should work fine
# If we want to enforce the HTTP spec later, do this:
#if linei == line.len: httpError("Invalid headers - no header value after colon")
This conversation was marked as resolved.
Show resolved Hide resolved
# Remember the header name for the possible multi-line header
lastHeaderName = name
result.headers.add(name, line[linei .. ^1].strip())
Expand Down
Loading