-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Disallow negative or hexadecimal content-length headers. #49305
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
Comments
@itsjustkevin - do we no longer need approval from Hixie and grouma? |
the breaking change lgtm, not sure who else needs to approve it. |
LGTM |
lgtm |
LGTM |
Fixed in 981bcf6 |
@brianquinlan just want to clarify for my own understanding (and documentation),
Did you bring this up because Or, did you mean that the statement on the api docs page "The value is negative if there is no content length set." doesn't need to change, because it's equivalent to the statement you made "a negative value means remove the header completely." |
Change
Generate a
HttpException
whenHttpHeaders.add(...)
encounters a negative or hexadecimal encodedcontent-length
. Currently both are acceptable.Also, change non-numeric input to raise a
HttpException
rather than aFormatException
so that a consistentException
is thrown.Rationale
RFC 7230 says that the production for
content-length
is:So we are currently accepting invalid input that might cause clients/servers to misbehave.
The possibility of
HttpHeaders.add(...)
throwingFormatException
is undocumented so (partially) consolidate toHttpException
(which is what is what is thrown for most parse failures).Impact
This change does not break any Google tests.
Note that this does not change the semantics of the
HttpHeaders.contentLength
property where a negative value means remove the header completely.Mitigation
Users should not use
HttpHeaders.add(...)
to setcontent-length
headers that are not allowed by the RFC.The text was updated successfully, but these errors were encountered: