[FIX] tools, base, mail: add a fallback when parsing wrongly-formatted emails
With input 'name email@domain.com' (missing chevrons allowing to clearly spot the email part) 'getaddresses' returns ('', 'name email@domain.com) i.e. the whole input is considered as being the email. To improve the heuristic we can add a fallback by recalling 'getadresses' on the input with spaces replaced by commas when it found only an email and no name. The new email will be split into sub pairs allowing to find the real email and various name parts, allowing to make a new name / email pair. Emails should not contain spaces thus this is coherent with email formation. This fallback actually comes from a specific code done in '_parse_partner_name' of Partner model. Supporting it directly at tools level make the behavior coherent for all models. Task-2612945 (Mail: Defensive email formatting) Part-of: odoo/odoo#74474
Showing
- addons/test_mass_mailing/tests/test_mailing.py 2 additions, 2 deletionsaddons/test_mass_mailing/tests/test_mailing.py
- odoo/addons/base/models/res_partner.py 3 additions, 7 deletionsodoo/addons/base/models/res_partner.py
- odoo/addons/base/tests/test_mail.py 4 additions, 4 deletionsodoo/addons/base/tests/test_mail.py
- odoo/tools/mail.py 27 additions, 6 deletionsodoo/tools/mail.py
Loading
Please register or sign in to comment