Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
bpo-44637: Fix DBQuote mail header refold#29881
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
When a header content is too long, the RFC demands to fold it overmultiple lines. Each line starting with a space to denote folded-linesfrom regular ones.Folding a line requires splitint it, there are only a few sweet spotswhere it is possible to do so (e.g. between two words). Words are prettydeep in the parse-tree thus multiple parts must be unwrap to revealthem. One of those parts can be a quoted-string, printing aquoted-string as a whole correctly wraps its content with double-quotesbut printing every child never quotes them.When a quoted-string must be unwrap to find a sweet-splot to split theline, we now inject double-quotes literals before and after itschildren.
The email refolding algorithm was wrongly removing double-quotes, we now make sure they are correctly inserted when a BareQuotedString part is unwrap. I tried several other approaches in ordernot to bloat the |
Not sure it deserves a message in the news, you tell me. |
I tested the changes by sending myself an email with a forged message. Server is postfix, client is Thunderbird. |
This PR is stale because it has been open for 30 days with no activity. |
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.
All email test ok apart from
test_utf8_input_no_charset
Looks ok to me.
@warsaw could you review (and merge if possible) this PR? The fixed problem has a real-world impact (#88803 (comment)):
|
I'm not familiar with the |
gazfaris left a comment
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.
Compiles, without errors
up, it has been over a year, the issue is still affecting us, it has a clear commit message, tests and all checks are successful |
Uh oh!
There was an error while loading.Please reload this page.
When a header content is too long, the RFC demands to fold it over
multiple lines. Each line starting with a space to denote folded-lines
from regular ones.
Folding a line requires splitint it, there are only a few sweet spots
where it is possible to do so (e.g. between two words). Words are pretty
deep in the parse-tree thus multiple parts must be unwrap to reveal
them. One of those parts can be a quoted-string, printing a
quoted-string as a whole correctly wraps its content with double-quotes
but printing every child never quotes them.
When a quoted-string must be unwrap to find a sweet-splot to split the
line, we now inject double-quotes literals before and after its
children.
https://bugs.python.org/issue44637