Add .svg to select_jinja_autoescape
This commit is contained in:
parent
3dc6db9d0c
commit
f87623f8d7
4 changed files with 12 additions and 2 deletions
|
|
@ -9,6 +9,8 @@ Version 2.2.3
|
||||||
|
|
||||||
Unreleased
|
Unreleased
|
||||||
|
|
||||||
|
- Autoescaping is now enabled by default for ``.svg`` files. Inside
|
||||||
|
templates this behavior can be changed with the ``autoescape`` tag.
|
||||||
|
|
||||||
Version 2.2.2
|
Version 2.2.2
|
||||||
-------------
|
-------------
|
||||||
|
|
|
||||||
|
|
@ -436,6 +436,11 @@ Here is a basic introduction to how the :class:`~markupsafe.Markup` class works:
|
||||||
>>> Markup('<em>Marked up</em> » HTML').striptags()
|
>>> Markup('<em>Marked up</em> » HTML').striptags()
|
||||||
'Marked up » HTML'
|
'Marked up » HTML'
|
||||||
|
|
||||||
|
.. versionchanged:: 2.2
|
||||||
|
|
||||||
|
In addition to the extensions below, templates with the ``.svg`` extension
|
||||||
|
are also autoescaped.
|
||||||
|
|
||||||
.. versionchanged:: 0.5
|
.. versionchanged:: 0.5
|
||||||
|
|
||||||
Autoescaping is no longer enabled for all templates. The following
|
Autoescaping is no longer enabled for all templates. The following
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ Jinja Setup
|
||||||
Unless customized, Jinja2 is configured by Flask as follows:
|
Unless customized, Jinja2 is configured by Flask as follows:
|
||||||
|
|
||||||
- autoescaping is enabled for all templates ending in ``.html``,
|
- autoescaping is enabled for all templates ending in ``.html``,
|
||||||
``.htm``, ``.xml`` as well as ``.xhtml`` when using
|
``.htm``, ``.xml``, ``.xhtml``, as well as ``.svg`` when using
|
||||||
:func:`~flask.templating.render_template`.
|
:func:`~flask.templating.render_template`.
|
||||||
- autoescaping is enabled for all strings when using
|
- autoescaping is enabled for all strings when using
|
||||||
:func:`~flask.templating.render_template_string`.
|
:func:`~flask.templating.render_template_string`.
|
||||||
|
|
|
||||||
|
|
@ -961,11 +961,14 @@ class Flask(Scaffold):
|
||||||
"""Returns ``True`` if autoescaping should be active for the given
|
"""Returns ``True`` if autoescaping should be active for the given
|
||||||
template name. If no template name is given, returns `True`.
|
template name. If no template name is given, returns `True`.
|
||||||
|
|
||||||
|
.. versionchanged:: 2.2
|
||||||
|
Autoescaping is now enabled by default for ``.svg`` files.
|
||||||
|
|
||||||
.. versionadded:: 0.5
|
.. versionadded:: 0.5
|
||||||
"""
|
"""
|
||||||
if filename is None:
|
if filename is None:
|
||||||
return True
|
return True
|
||||||
return filename.endswith((".html", ".htm", ".xml", ".xhtml"))
|
return filename.endswith((".html", ".htm", ".xml", ".xhtml", ".svg"))
|
||||||
|
|
||||||
def update_template_context(self, context: dict) -> None:
|
def update_template_context(self, context: dict) -> None:
|
||||||
"""Update the template context with some commonly used variables.
|
"""Update the template context with some commonly used variables.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue