From 82cae4fc89a91d36600e8d0d1f829fe4befe374e Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Thu, 24 Mar 2022 18:37:13 +0000 Subject: [PATCH] Revert "Replace instances of deprecated `Jinja2.Markup` with `markupsafe.Markup` (#12289)" This reverts commit 8810c93e828a9ed1dcb008d08be8aa9fcb4d28c3. --- synapse/push/mailer.py | 9 ++++----- synapse/python_dependencies.py | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py index 5ccdd88364d7..649a4f49d024 100644 --- a/synapse/push/mailer.py +++ b/synapse/push/mailer.py @@ -18,7 +18,6 @@ import bleach import jinja2 -from markupsafe import Markup from synapse.api.constants import EventTypes, Membership, RoomTypes from synapse.api.errors import StoreError @@ -868,7 +867,7 @@ def _make_unsubscribe_link( ) -def safe_markup(raw_html: str) -> Markup: +def safe_markup(raw_html: str) -> jinja2.Markup: """ Sanitise a raw HTML string to a set of allowed tags and attributes, and linkify any bare URLs. @@ -878,7 +877,7 @@ def safe_markup(raw_html: str) -> Markup: Returns: A Markup object ready to safely use in a Jinja template. """ - return Markup( + return jinja2.Markup( bleach.linkify( bleach.clean( raw_html, @@ -892,7 +891,7 @@ def safe_markup(raw_html: str) -> Markup: ) -def safe_text(raw_text: str) -> Markup: +def safe_text(raw_text: str) -> jinja2.Markup: """ Sanitise text (escape any HTML tags), and then linkify any bare URLs. @@ -902,7 +901,7 @@ def safe_text(raw_text: str) -> Markup: Returns: A Markup object ready to safely use in a Jinja template. """ - return Markup( + return jinja2.Markup( bleach.linkify(bleach.clean(raw_text, tags=[], attributes=[], strip=False)) ) diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 232f9a959570..1dd39f06cffb 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -75,7 +75,6 @@ "attrs>=19.2.0,!=21.1.0", "netaddr>=0.7.18", "Jinja2>=2.9", - "MarkupSafe>=2.0", "bleach>=1.4.3", # We use `ParamSpec`, which was added in `typing-extensions` 3.10.0.0. "typing-extensions>=3.10.0",