-
Notifications
You must be signed in to change notification settings - Fork 851
Fix: reject '@' in HTTP header field names per RFC 9110 #12838
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
base: master
Are you sure you want to change the base?
Fix: reject '@' in HTTP header field names per RFC 9110 #12838
Conversation
RFC 9110 defines HTTP header field names as tokens, which must not contain '@'. Currently '@' is accepted because of MIME separator handling. This patch ensures ParseRules::is_http_field_name rejects '@', aligning behavior with RFC 9110. This prevents invalid header names from being accepted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes HTTP header field name validation to comply with RFC 9110 by rejecting the '@' character. The current implementation incorrectly accepts '@' due to MIME separator handling logic.
Changes:
- Removed the exception that allowed '@' in HTTP header field names
- Updated the validation logic to properly reject all MIME separators including '@'
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| #ifndef COMPILE_PARSE_RULES | ||
| return (parseRulesCType[static_cast<unsigned char>(c)] & is_token_BIT); | ||
| return (parseRulesCType[(unsigned char)c] & is_token_BIT); |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from static_cast<unsigned char> to C-style cast (unsigned char). C++ best practice is to use static_cast for type safety and clarity. This change appears unrelated to the PR's stated purpose of fixing '@' validation.
| return (parseRulesCType[(unsigned char)c] & is_token_BIT); | |
| return (parseRulesCType[static_cast<unsigned char>(c)] & is_token_BIT); |
| { | ||
| #ifndef COMPILE_PARSE_RULES | ||
| return (parseRulesCType[static_cast<unsigned char>(c)] & is_token_BIT); | ||
| return (parseRulesCType[(unsigned char)c] & is_token_BIT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no C casts, please
RFC 9110 defines HTTP header field names as tokens, which must not contain '@'.
Currently '@' is accepted because of MIME separator handling.
This patch ensures ParseRules::is_http_field_name rejects '@', aligning behavior with RFC 9110.
This prevents invalid header names from being accepted.