diff --git a/CHANGES.rst b/CHANGES.rst index eb46957df..2c7e6f9cd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,8 @@ Unreleased - Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``. :pr:`1793` - Use ``flit_core`` instead of ``setuptools`` as build backend. +- Fixed `autoescape=False` not working for builtin filter `tojson`. + :issue:`1934` Version 3.1.3 diff --git a/src/jinja2/filters.py b/src/jinja2/filters.py index 38ca333b2..545dd8958 100644 --- a/src/jinja2/filters.py +++ b/src/jinja2/filters.py @@ -1,4 +1,5 @@ """Built-in template filters used with the ``|`` operator.""" +import json import math import random import re @@ -1680,9 +1681,9 @@ async def do_rejectattr( @pass_eval_context def do_tojson( eval_ctx: "EvalContext", value: t.Any, indent: t.Optional[int] = None -) -> Markup: +) -> t.Union[str, Markup]: """Serialize an object to a string of JSON, and mark it safe to - render in HTML. This filter is only for use in HTML documents. + render in HTML if autoescape. The returned string is safe to render in HTML documents and ``