Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Revert "Replace instances of deprecated Jinja2.Markup with `markups…
Browse files Browse the repository at this point in the history
…afe.Markup`" (#12296)

This reverts commit 8810c93.
  • Loading branch information
anoadragon453 committed Mar 24, 2022
1 parent e689cae commit 0004260
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions synapse/push/mailer.py
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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.
Expand All @@ -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))
)

Expand Down
1 change: 0 additions & 1 deletion synapse/python_dependencies.py
Expand Up @@ -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",
Expand Down

0 comments on commit 0004260

Please sign in to comment.