-
-
Notifications
You must be signed in to change notification settings - Fork 34k
gh-143916: Allow HTAB in wsgiref header values #144118
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: main
Are you sure you want to change the base?
Conversation
| self._convert_string_type(v) | ||
|
|
||
| def _convert_string_type(self, value): | ||
| def _convert_string_type(self, value, *, name=False): |
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.
It may be safer to always require the name parameter:
| def _convert_string_type(self, value, *, name=False): | |
| def _convert_string_type(self, value, *, name): |
| """Convert/check value type.""" | ||
| if type(value) is str: | ||
| if _control_chars_re.search(value): | ||
| if (_name_disallowed_re if name else _value_disallowed_re).search(value): |
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.
nitpick: I would prefer to write this code on two lines for better readability:
| if (_name_disallowed_re if name else _value_disallowed_re).search(value): | |
| regex = (_name_disallowed_re if name else _value_disallowed_re) | |
| if regex.search(value): |
| headers = Headers() | ||
| self.assertRaises(ValueError, headers.__setitem__, f"key{c0}", "val") | ||
| self.assertRaises(ValueError, headers.add_header, f"key{c0}", "val", param="param") | ||
| # HTAB is allowed in values, not names. |
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.
| # HTAB is allowed in values, not names. | |
| # HTAB (\x09) is allowed in values, not names. |
|
See also PR gh-144371 which rejects control characters in |
In #143917 we were overzealous,
HTAB(0x09) is allowed in header values but not header names.