summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-02-27 13:16:11 (GMT)
committerGuido van Rossum <guido@python.org>1995-02-27 13:16:11 (GMT)
commiteb9e9d2b2a61629e7562587a679367c3bb52c92b (patch)
treefdff5687f49afe562678694b2e5a14d9aefa9a50 /Lib/cgi.py
parentc7acf2a106caacc11397e35afe054816fd6181fa (diff)
downloadcpython-eb9e9d2b2a61629e7562587a679367c3bb52c92b.zip
cpython-eb9e9d2b2a61629e7562587a679367c3bb52c92b.tar.gz
cpython-eb9e9d2b2a61629e7562587a679367c3bb52c92b.tar.bz2
layout changes; quote & as well
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index d412109..a9599a7 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -242,23 +242,30 @@ set:</H3> <UL>
def print_environ():
skeys = environ.keys()
skeys.sort()
- print '<h3> The following environment variables were set by the CGI script: </H3>'
+ print '<h3> The following environment variables ' \
+ 'were set by the CGI script: </h3>'
print '<dl>'
for key in skeys:
- print '<dt>',key, '<dd>', environ[key]
+ print '<dt>', escape(key), '<dd>', escape(environ[key])
print '</dl>'
def print_form( form ):
- print '<h3> The following name/value pairs were entered in the form:</h3>'
- print '<dl>'
skeys = form.keys()
skeys.sort()
+ print '<h3> The following name/value pairs ' \
+ 'were entered in the form: </h3>'
+ print '<dl>'
for key in skeys:
- print '<dt>',key, ' : <i> ',escape(`type(form[key])`),' </i>','<dd>', form[key]
+ print '<dt>', escape(key), ':',
+ print '<i>', escape(`type(form[key])`), '</i>',
+ print '<dd>', escape(form[key])
print '</dl>'
def escape( s ):
- return regsub.gsub( '<', '&lt;', regsub.gsub( '>' , '&gt;', s ))
+ s = regsub.gsub('&', '&amp;') # Must be done first
+ s = regsub.gsub('<', '&lt;')
+ s = regsub.gsub('>', '&gt;')
+ return s
def test( what ):
label = escape(str(what))