summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 20f4700..4f1b459 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -1316,12 +1316,14 @@ environment as well. Here are some common variable names:
# Utilities
# =========
-def escape(s):
+def escape(s, quote=None):
"""Replace special characters '&', '<' and '>' by SGML entities."""
import regsub
s = regsub.gsub("&", "&amp;", s) # Must be done first!
s = regsub.gsub("<", "&lt;", s)
s = regsub.gsub(">", "&gt;", s)
+ if quote:
+ s = regsub.gsub('"', "&quot;", s)
return s