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

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


Bugs item #633504, was opened at 2002-11-04 16:51
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=633504&group_id=5470

Category: Python Library
Group: Python 2.2
>Status: Closed
>Resolution: Rejected
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.: 
<pre>
...
    elif sys.argv[1:]:
        if qs: qs = qs + '&'
        qs = qs + sys.argv[1]
...
</pre>

A simple patch to fix this follows:
<pre>
216c216
<             continue
---
>             else: nv.append('')
</pre>

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



----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-11-15 11:48

Message:
Logged In: YES 
user_id=6380

If you want arguments that don't follow the keyword=value
format, you can parse sys.argv yourself -- you don't need
the cgi module for that.

I'm rejecting this request.

----------------------------------------------------------------------

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

Message:
Logged In: YES 
user_id=642367

#!/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 18:10

Message:
Logged In: YES 
user_id=6380

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: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=633504&group_id=5470