[MERGE] base/mail: fix multiple issues in email address handling after #35929#39516
[MERGE] base/mail: fix multiple issues in email address handling after #35929#39516Julien00859 wants to merge 3 commits intoodoo:masterfrom
Conversation
648f4c7 to
d83fe11
Compare
d83fe11 to
fef1eaf
Compare
fef1eaf to
58e0b72
Compare
odony
left a comment
There was a problem hiding this comment.
spell-checking, couldn't resist ;)
formataddr() behavior (more P2-like)
58e0b72 to
402cb25
Compare
|
All done, thank you for the extensive review 😃 |
402cb25 to
000540f
Compare
000540f to
ed12b33
Compare
|
Hello @odony can we merge this one ? 🙂 |
tde-banana-odoo
left a comment
There was a problem hiding this comment.
Thanks for the followup, seems like a good work :)
It seems the emails > < are missing. By the way one manual formataddr is replaced by an email_formatted field. Result is the same but let us use fields doing it for us.
Python 2 `email.tools.formataddr` doesn't encode not RFC-2822 compliant realname to base64 or quoted-printable. This is the wanted behavior to output formatted email addresses on screen. Python 3 `email.tools.formataddr` does encode the realname to be RFC-2822 compliant. This is the wanted behavior when connecting to a smtp server to send emails. That method has been deprecated by pep-594 as the new python email API is capable of automatically formatting email address in a RFC compliant way. As the method was still in use in a lot of modules as the preferred way to format email addresses, a refined P3-like implementation as been included in the tool suite. This commit changes the default behavior so it mimics P2 implementation with an easy way to use the P3 behavior. Task: 2003936
ed12b33 to
bbd9243
Compare
|
There is a customer on v13 that is affected by the py3 behavior, if it is possible to review this one so I can backport it there |
Problem description: Using the chatter, send an email to someone having non-ascii characters in their name: the body of the received email looks like it contains a mix of the original body and headers. Python encodes the name into either base64 or quoted-printable but leaves some redundant carriage returns at the end of the header. Those redundant carriage returns are not RFC conformant but are interpreted as newlines by some email clients, thus are read like a headers/body separator and the next headers are considered part of the body, corrupting the email structure. This problem is internal to Python and has been fixed in 3.8, cfr bpo-34424 [1], and later backported to 3.7.4. As we also support 3.6 and earlier 3.7 and it is not possible to easily monkey-patch the function, we fixed it by squashing duplicate carriage returns. (There is no case where a series of bare CRs can occur in a normal RFC5322 email message) Task: 2003936 [1]: https://bugs.python.org/issue34424
bbd9243 to
3e39a9b
Compare
formataddr() behavior (more P2-like)|
Merge method set to rebase and merge, using the PR as merge commit message |
Could you elaborate on what you intend to do? This PR is an afterthought on top of #35929, and it cannot be cherry-picked in 13.0 at all as far as I can see. For instance the old email API did not perform the appropriate header encoding transparently, did it? |
|
@odony opw-2115767, a customer is having problem in v13 because the python formataddr show the name as quoted printable instead of utf-8 on various form views, this prevent him from migrating from v12 (where the names are showed in utf-8). My plan is to backport c024d89 (our own formataddr), a66e16e (tde's fix) and 81003c1 (p2 behavior) |
|
Merged at 7352f0d, thanks! |
[FIX] tools: correctly format emails when having an encoding issue
[IMP] tools: restore P2 formataddr default behavior
[FIX] ir.mail.server: squash redundant CRs (bpo-34424)
Task: 2003936