| Index: Lib/cgi.py |
| =================================================================== |
| --- Lib/cgi.py (revision 84355) |
| +++ Lib/cgi.py (working copy) |
| @@ -38,6 +38,7 @@ |
| import urllib.parse |
| import email.parser |
| from warnings import warn |
| +import html |
| __all__ = ["MiniFieldStorage", "FieldStorage", |
| "parse", "parse_qs", "parse_qsl", "parse_multipart", |
| @@ -899,15 +900,10 @@ |
| # ========= |
| def escape(s, quote=None): |
| - '''Replace special characters "&", "<" and ">" to HTML-safe sequences. |
| - If the optional flag quote is true, the quotation mark character (") |
| - is also translated.''' |
| - s = s.replace("&", "&") # Must be done first! |
| - s = s.replace("<", "<") |
| - s = s.replace(">", ">") |
| - if quote: |
| - s = s.replace('"', """) |
| - return s |
| + """Deprecated API.""" |
| + warn("cgi.escape is deprecated, use html.escape instead", |
| + PendingDeprecationWarning) |
| + return html.escape(s, quote) |
| def valid_boundary(s, _vb_pattern="^[ -~]{0,200}[!-~]$"): |
| import re |