-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
ValueError is raised instead of InvalidHeader #6083
Comments
In As per the IMF (refer https://www.rfc-editor.org/rfc/rfc2822#section-2.2)
I figured the fix for this one (the regex for validating header name goes like this |
Thanks for volunteering @Khasim481. The RFC linked is quite old and has been obsolete for almost a decade. I believe you're looking for the definition in the current RFC 7230. You'll find the exact ABNF is 1 or more We strictly adhere to the spec for field-values but it's correct we omitted the field-name when this was first done. The change was explicitly to solve security risks with header values. This issue is more cosmetic, but I do agree we should have consistency with the error type. We actually already have a branch in place with most of the fix for this but it's still needs some final refactoring. |
The changes in the branch looks perfect, If you mention those cosmetic changes broadly here, I can be of help. |
@Khasim481 Any estimation when this will be fixed? |
It's currently a candidate fix for the next release, 2.28.0. |
This has been merged in #6154 and will be available in the next release. Thanks everyone! |
When using an invalid header name it is not checked in the
requests.utils.check_header_validity
function, only the value is checked.This causes the underline HTTPConnection to fail when trying to write the header on
ValueError
, seems like that it is checked against:_is_legal_header_name = re.compile(rb'[^:\s][^:\r\n]*').fullmatch
The expected exception, in this case, will be
InvalidHeader
System Information
The text was updated successfully, but these errors were encountered: