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