-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-105973: Ensure that http
header parser returns RFC 7230 compliant header values
#105994
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
…e from header values This adds a test to check for the behaviour identified in python#105973
…ations Although python#105973 is promarily concerned with trailing whitespace not being stripped, it's easy/inexpensive to test for other whitespace behaviour (to detect any other future incompatabilities). This test change ensures that - Leading whitespace is trimmed from header values - Whitespace in the middle of a header value is not removed
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.
Would it be possible to adjust email.policy.HTTP
, rather than applying a post-process on the headers?
In principle, I think so, yes:
As long as the new attribute defaults to false (preserving current behaviour) there should be a low likelihood of impacting anything else.
|
f832b21
to
2df334b
Compare
Ooops, rebased after syncing the branch - has pulled other people's commits into this PR. Fixing that now. |
2df334b
to
237c7ff
Compare
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
…mstances This adds a new attribute `allow_trailing_whitespace` to `EmailPolicy` and `Policy` and amends `header_source_parse` to consider it's state. This currently works when `allow_trailing_whitespace` is manually coerced to `False`, but does not appear to be working with `http.client`'s invocations
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
@barneygale it turns out that The branch has been rebased to remove my original changes (apart from the tests), and the requested changes to |
Looks like it's blown up a few tests - the way the Date header is handled looks to have changed (upsetting the urllib test). Also looks like quoting of strings in values has been lost. Will try find time later to fix these |
The original name was too long and disrupted the layout of docstrings and test definitions.
I ran into an issue, so wanted to lay it out here for clarity - moving the change to
Changing that, though, led to tests in other modules failing (quite reasonably) because it led to changes in response behaviour. For example, passing
This happens because the change in policy means the value is now passed through Whilst the result is legal in HTTP, it's a change in behaviour which might cause issues downstream. As an easy example of this, it breaks this test.
There are other changes to response formats too, So, in order to preserve existing behaviour whilst applying the trailing space fix, I've adjusted That change fixes the issue (but currently breaks the email tests). @barneygale I wanted to check which you'd prefer:
|
This change will break a number of `email` tests because `Compat32` does not currently explicitly contain (or document) certain attributes
Looking at it with fresh eyes this morning has helped. The issue (after switching to using |
All tests passed. Ready for review at your convenience @barneygale |
Related are these PR and issue (feature request) I opened: #105918 and #105622. tl;dr they would change I actually like using Or, both PRs could be combined in a way. Currently this PR clones |
Just a gentle nudge - any chance of getting a review on this please? |
http
usesemail
header parser but they have slightly different rules about whitespace #105973