diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 331cdc61e6..c996c7155f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,12 @@ == Version 2.5.17 Work in progress (not released -- this is a draft) == + Users side : + ------------ + # Apps : + * Emails : + - The email form uses HTML line breaks when the HTML body is copied + from the plain text body. + Developers side : ----------------- diff --git a/creme/emails/forms/mail.py b/creme/emails/forms/mail.py index 6e45ad55b7..0cb6a5c45a 100644 --- a/creme/emails/forms/mail.py +++ b/creme/emails/forms/mail.py @@ -1,6 +1,6 @@ ################################################################################ # Creme is a free/open-source Customer Relationship Management software -# Copyright (C) 2009-2022 Hybird +# Copyright (C) 2009-2025 Hybird # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -24,7 +24,7 @@ from django.core.exceptions import ValidationError from django.core.validators import validate_email from django.db.transaction import atomic -from django.utils.html import escape +from django.utils.html import linebreaks # escape from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ from django.utils.translation import pgettext_lazy @@ -196,7 +196,8 @@ def save(self): body = get_data('body') or strip_html(get_data('body_html')).strip() body_html = ( get_data('body_html') - or f'{escape(body)}' + # or f'{escape(body)}' + or f'{linebreaks(body, autoescape=True)}' ) signature = get_data('signature') attachments = get_data('attachments') diff --git a/creme/emails/tests/test_mail.py b/creme/emails/tests/test_mail.py index 1ad1b497a6..1b05fae841 100644 --- a/creme/emails/tests/test_mail.py +++ b/creme/emails/tests/test_mail.py @@ -346,7 +346,7 @@ def test_createview_empty_body01(self): self.assertFalse(html_f.required) sender = user.linked_contact.email - body = 'Fresh & tasty !' + body = 'Fresh & tasty!\nTry it now!' response2 = self.client.post( url, data={ @@ -363,7 +363,7 @@ def test_createview_empty_body01(self): email = self.get_object_or_fail(EntityEmail, sender=sender, recipient=recipient) self.assertEqual(body, email.body) self.assertEqual( - 'Fresh & tasty !', + '

Fresh & tasty!
Try it now!

', email.body_html, )