-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143916: Reject control characters in wsgiref.headers.Headers #143917
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?
gh-143916: Reject control characters in wsgiref.headers.Headers #143917
Conversation
| self.assertRaises(ValueError, headers.__setitem__, f"key{c0}", "val") | ||
| self.assertRaises(ValueError, headers.__setitem__, "key", f"val{c0}") | ||
| self.assertRaises(ValueError, headers.add_header, f"key{c0}", "val", param="param") | ||
| self.assertRaises(ValueError, headers.add_header, "key", f"val{c0}", param="param") | ||
| self.assertRaises(ValueError, headers.add_header, "key", "val", param=f"param{c0}") |
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.
Consider marking params as subtests for better test report.
| self.assertRaises(ValueError, headers.__setitem__, f"key{c0}", "val") | |
| self.assertRaises(ValueError, headers.__setitem__, "key", f"val{c0}") | |
| self.assertRaises(ValueError, headers.add_header, f"key{c0}", "val", param="param") | |
| self.assertRaises(ValueError, headers.add_header, "key", f"val{c0}", param="param") | |
| self.assertRaises(ValueError, headers.add_header, "key", "val", param=f"param{c0}") | |
| with self.subTest(control_character=hex(ord(c0[0]))): | |
| self.assertRaises(ValueError, headers.__setitem__, f"key{c0}", "val") | |
| self.assertRaises(ValueError, headers.__setitem__, "key", f"val{c0}") | |
| self.assertRaises(ValueError, headers.add_header, f"key{c0}", "val", param="param") | |
| self.assertRaises(ValueError, headers.add_header, "key", f"val{c0}", param="param") | |
| self.assertRaises(ValueError, headers.add_header, "key", "val", param=f"param{c0}") |
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.
Are you okay if I don't adopt subTest() here? I ask because I have many other PRs out that I'd need to modify, too.
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.
Sure, I won't insist. It's just that I usually try to make logical tests obvious. It's typically easier in newly added lines rather than when refactoring existing tests.
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 is not really needed. We will see the failing line. We do not extensively use subTest as well, only when it really is needed (it adds indentation)
Uh oh!
There was an error while loading. Please reload this page.