Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(94953)

Unified Diff: Lib/cgi.py

Issue 2830: Copy cgi.escape() to html
Patch Set: Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Doc/library/markup.rst ('k') | Lib/html/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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("&", "&amp;") # Must be done first!
- s = s.replace("<", "&lt;")
- s = s.replace(">", "&gt;")
- if quote:
- s = s.replace('"', "&quot;")
- 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
« no previous file with comments | « Doc/library/markup.rst ('k') | Lib/html/__init__.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+