summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2021-04-21 12:09:31 +0000
committerJulien Castiaux <juc@odoo.com>2021-04-26 08:27:12 +0000
commit94849f6545e96d0823bd29cef7fa111b82ed3b28 (patch)
tree734e46e189cd0abfab4f14cb9663ecad75544e3d /addons
parentcbed573e6146a0aab6e0e9114be515a347cd10a4 (diff)
[FIX] mail: sanitize dots in generated mail alias
Create a company whoose name ends with a dot like "Bidule Inc.", change the company of the user to that new company, head to the Accouning module and create a new journal of type purchase. Traceback because the generated mail alias for that journal uses the company name and that the local-part of an email cannot ends with a dot. From the RFC standpoint, the local-part of an email address (the part before the @, `john` in `"John Doe" <john@example.com>`, cannot begins with, ends with or contain following dots. The email sanitizing function have been updated so it takes care of the above requirement. See also #61811 opw-2448692 closes odoo/odoo#69816 Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/models/mail_alias.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/addons/mail/models/mail_alias.py b/addons/mail/models/mail_alias.py
index 28d4f1b0192..7ccb1f13975 100644
--- a/addons/mail/models/mail_alias.py
+++ b/addons/mail/models/mail_alias.py
@@ -142,6 +142,7 @@ class Alias(models.Model):
name already exists an UserError is raised. """
sanitized_name = remove_accents(name).lower().split('@')[0]
sanitized_name = re.sub(r'[^\w+.]+', '-', sanitized_name)
+ sanitized_name = re.sub(r'^\.+|\.+$|\.+(?=\.)', '', sanitized_name)
sanitized_name = sanitized_name.encode('ascii', errors='replace').decode()
catchall_alias = self.env['ir.config_parameter'].sudo().get_param('mail.catchall.alias')