[Python-bugs-list] [ python-Bugs-633504 ] cgi.py drops commandline arguments

noreply@sourceforge.net noreply@sourceforge.net
Fri, 15 Nov 2002 08:00:08 -0800

Bugs item #633504, was opened at 2002-11-04 21:51
You can respond by visiting: 

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Randall Randall (randallrandall)
Assigned to: Nobody/Anonymous (nobody)
Summary: cgi.py drops commandline arguments

Initial Comment:
Keyword arguments in URLs are currently ignored by the
cgi.parse_qsl() function, even though they are
explicitly included by cgi.parse(), i.e.: 
    elif sys.argv[1:]:
        if qs: qs = qs + '&'
        qs = qs + sys.argv[1]

A simple patch to fix this follows:
<             continue
>             else: nv.append('')

This fix doesn't affect those using strictparsing=1 ,
which will still fail to include anything without an
equals ('=').


>Comment By: Randall Randall (randallrandall)
Date: 2002-11-15 16:00

Logged In: YES 

#!/usr/bin/env python2
# source of test.cgi
# when called with a URL like 
# http://www.example.com/test.cgi?toggle
# this will only print 'yes' if form 
# variables without '=' are allowed.
# These are called ISINDEX values, and
# are sent to the commandline of the cgi
# program, if any.  Since the commandline
# is searched for form variables, it's 
# clear that they were intended to be 
# included when parsing incoming form 
# variables, but the current cgi.py 
# discards them because they do not 
# conform to a pair of strings separated
# by an equals sign.
# This behavior is not strictly necessary 
# for implementing any cgi program, but
# has a positive marketing value, the 
# difference between 
# http://www.example.com/test.cgi?myname
# and
# http://www.example.com/test.cgi?user=myname

import cgi

form = cgi.FieldStorage(keep_blank_values=1)
print 'Content-type: text/plain\n\n'
if form.has_key('toggle'): print 'yes'  
else: print 'no'


Comment By: Guido van Rossum (gvanrossum)
Date: 2002-11-14 23:10

Logged In: YES 

I'd be willing to have this fixed, if I could understand the
problem. Can you show an example program and how it does not
do what you expect?


You can respond by visiting: