-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
IndexDefect
in httpclient because of a header spanning multiple lines
#19261
Comments
IndexDefect
in httpclient because of a weird header in response IndexDefect
in httpclient because of a header spanning multiple lines
Also, seems like that code uses |
I'm trying to make a simple patch to try to fix it, but the |
I think I have a solution, but it might break backwards compatibility if someone relied on this behaviour because From https://datatracker.ietf.org/doc/html/rfc7230#section-3.2:
Definition of
The spec forbids spaces before the header name and after the header name before I can make a more or less clean fix for this issue if I change the httpclient to follow the spec more strictly. |
Also, from my manual testing, if there is leading whitespace before the header, then both Chromium and Firefox just append it to the previous one, so we should make The behaviour for whitespace after the header name before the colon differs though - Chromium parses it as a valid header while Firefox discards the header. So I'm not sure if we should enforce the spec like Firefox does, or be more lax like Chromium. |
In my opinion, we should enforce the spec. |
Yes, follow spec always :) |
Continuation of #19262 Fixes #19261 The parsing code is still too lenient (e.g. it will happily parse header names with spaces in them, which is outright invalid by the spec), but I didn't want to touch it beyond the simple changes to make sure that `std/httpclient` won't throw `IndexDefect`s like it does now on those cases: - Multiline header values - No colon after the header name - No value after the header name + colon One question remains - should I keep `toCaseInsensitive` exported in `httpcore` or just copy-paste the implementation? --------- Co-authored-by: Andreas Rumpf <[email protected]>
I was doing some scanning stuff and found a host that replies with one header that spans multiple lines. Chromium seems to be happy with it, but
httpclient
does an out of bounds access which results in IndexDefect.Example
No usable-by-default Nim repro code yet, but here's the whole response from the server:
Notice how
Content-Security-Policy
spans multiple lines.Current Output
Expected Output
No error from
httpclient
, and it should parse that header into a single line, like Chromium:Additional Information
The text was updated successfully, but these errors were encountered: