bpo-44637: Fix DBQuote mail header refold#29881
bpo-44637: Fix DBQuote mail header refold#29881Julien00859 wants to merge 2 commits intopython:mainfrom
Conversation
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.
|
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 order not 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. |
MaxwellDupre
left a comment
There was a problem hiding this comment.
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 |
|
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 |
|
Got fixed at #122753 |

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