diff options
| -rw-r--r-- | CHANGES.rst | 1 | ||||
| -rw-r--r-- | docs/utils.rst | 8 | ||||
| -rw-r--r-- | src/werkzeug/utils.py | 49 |
3 files changed, 1 insertions, 57 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index cafd0612..dc014e0d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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` diff --git a/docs/utils.rst b/docs/utils.rst index c45e1dda..0d4e3391 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -4,16 +4,8 @@ Utilities Various utility functions shipped with Werkzeug. - -HTML Helpers -============ - .. module:: werkzeug.utils -.. autofunction:: escape - -.. autofunction:: unescape - General Helpers =============== diff --git a/src/werkzeug/utils.py b/src/werkzeug/utils.py index 3e4652bf..c13ab586 100644 --- a/src/werkzeug/utils.py +++ b/src/werkzeug/utils.py @@ -6,7 +6,6 @@ import re import sys import typing as t import unicodedata -import warnings from datetime import datetime from time import time from zlib import adler32 @@ -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": |
