From: Guido van Rossum Date: Sat, 19 Jul 1997 20:11:53 +0000 (+0000) Subject: Add optional 'quote' flag argument to escape(); if true, translate '"' X-Git-Tag: v1.5a3~208 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64c66209343edbdb212678759bc6e32a897b3a13;p=python Add optional 'quote' flag argument to escape(); if true, translate '"' to '"'. --- diff --git a/Lib/cgi.py b/Lib/cgi.py index 20f4700d7a..4f1b459493 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("&", "&", s) # Must be done first! s = regsub.gsub("<", "<", s) s = regsub.gsub(">", ">", s) + if quote: + s = regsub.gsub('"', """, s) return s