Project

General

Profile

Development #51374

misc: absence de {% autoescape %} dans certains templates de mail

Added by Benjamin Dauvergne 4 days ago. Updated 2 days ago.

Status:
Résolu (à déployer)
Priority:
Normal
Category:
-
Target version:
-
Start date:
23 Feb 2021
Due date:
% Done:

0%

Estimated time:
Patch proposed:
Yes
Planning:
No

Description

Ça semble avoir été rendu visible par un changement dans la façon de parser les query-string dans Django 2.2.19 (https://docs.djangoproject.com/en/3.1/releases/2.2.19/).


Files


Related issues

Has duplicate Authentic 2 - Bug #51376: build jenkins en échecRejeté23 Feb 2021

Actions

Associated revisions

Revision 562cb434 (diff)
Added by Benjamin Dauvergne 3 days ago

misc: use non-autoescaping template render for email text bodies and subjects (#51374)

History

#1

Updated by Benjamin Dauvergne 4 days ago

#2

Updated by Benjamin Dauvergne 4 days ago

  • Has duplicate Bug #51376: build jenkins en échec added
#4

Updated by Valentin Deniaud 4 days ago

  • Status changed from Solution proposée to En cours

(toujours rouge)

#5

Updated by Benjamin Dauvergne 4 days ago

Sans modifier la configuration globale c'est moins fatiguant.

#6

Updated by Valentin Deniaud 3 days ago

Pas fan du tout de ce render_plain_text_template_to_string, je préférais le premier patch. Sinon sans toucher aux backends cette approche semble fonctionner :

@@ -664,2 +665,3 @@ def send_templated_mail(user_or_email, template_names, context=None, with_html=T
         ctx.update(context)
+    plain_text_ctx = make_context(ctx, request=request, autoescape=False)

@@ -667,3 +669,4 @@ def send_templated_mail(user_or_email, template_names, context=None, with_html=T
     subject_template_names += legacy_subject_templates or []
-    subject = render_plain_text_template_to_string(subject_template_names, ctx, request=request).strip()
+    template = select_template(subject_template_names)
+    subject = template.template.render(plain_text_ctx).strip()

@@ -671,3 +674,4 @@ def send_templated_mail(user_or_email, template_names, context=None, with_html=T
     body_template_names += legacy_body_templates or []
-    body = render_plain_text_template_to_string(body_template_names, ctx, request=request)
+    template = select_template(body_template_names)
+    body = template.template.render(plain_text_ctx)
#8

Updated by Valentin Deniaud 2 days ago

  • Status changed from Solution proposée to Solution validée
#9

Updated by Benjamin Dauvergne 2 days ago

  • Status changed from Solution validée to Résolu (à déployer)
commit 562cb43476921eb071ad67161d9461b7d09e9c3c
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Feb 23 16:25:37 2021 +0100

    misc: use non-autoescaping template render for email text bodies and subjects (#51374)

Also available in: Atom PDF