Skip to content

Commit

Permalink
remove deprecated escape and unescape
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Nov 6, 2021
1 parent 70fc801 commit 22d1e9a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 57 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Unreleased
:meth:`Signature.bind` and :func:`inspect.signature` instead.
- Remove ``detect_utf_encoding``, it's built-in to ``json.loads``.
- Remove ``format_string``, use :class:`string.Template` instead.
- Remove ``escape`` and ``unescape``. Use MarkupSafe instead.

- Default values passed to ``Headers`` are validated the same way
values added later are. :issue:`1608`
Expand Down
8 changes: 0 additions & 8 deletions docs/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ Utilities

Various utility functions shipped with Werkzeug.


HTML Helpers
============

.. module:: werkzeug.utils

.. autofunction:: escape

.. autofunction:: unescape


General Helpers
===============
Expand Down
49 changes: 0 additions & 49 deletions src/werkzeug/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sys
import typing as t
import unicodedata
import warnings
from datetime import datetime
from time import time
from zlib import adler32
Expand Down Expand Up @@ -219,54 +218,6 @@ def secure_filename(filename: str) -> str:
return filename


def escape(s: t.Any) -> str:
"""Replace ``&``, ``<``, ``>``, ``"``, and ``'`` with HTML-safe
sequences.
``None`` is escaped to an empty string.
.. deprecated:: 2.0
Will be removed in Werkzeug 2.1. Use MarkupSafe instead.
"""
import html

warnings.warn(
"'utils.escape' is deprecated and will be removed in Werkzeug"
" 2.1. Use MarkupSafe instead.",
DeprecationWarning,
stacklevel=2,
)

if s is None:
return ""

if hasattr(s, "__html__"):
return s.__html__() # type: ignore

if not isinstance(s, str):
s = str(s)

return html.escape(s, quote=True) # type: ignore


def unescape(s: str) -> str:
"""The reverse of :func:`escape`. This unescapes all the HTML
entities, not only those inserted by ``escape``.
.. deprecated:: 2.0
Will be removed in Werkzeug 2.1. Use MarkupSafe instead.
"""
import html

warnings.warn(
"'utils.unescape' is deprecated and will be removed in Werkzueg"
" 2.1. Use MarkupSafe instead.",
DeprecationWarning,
stacklevel=2,
)
return html.unescape(s)


def redirect(
location: str, code: int = 302, Response: t.Optional[t.Type["Response"]] = None
) -> "Response":
Expand Down

0 comments on commit 22d1e9a

Please sign in to comment.