diff options
author | Guido van Rossum <guido@python.org> | 1997-07-19 20:11:53 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-07-19 20:11:53 +0000 |
commit | 64c66209343edbdb212678759bc6e32a897b3a13 (patch) | |
tree | bacbae5a61eacd67e9dff5363ccea97d1f99b70c /Lib/cgi.py | |
parent | 1e8c8a20f2b5ff51415ed8dfbf4df574595a95fb (diff) | |
download | cpython-git-64c66209343edbdb212678759bc6e32a897b3a13.tar.gz |
Add optional 'quote' flag argument to escape(); if true, translate '"'
to '"'.
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-x | Lib/cgi.py | 4 |
1 files changed, 3 insertions, 1 deletions
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 |