Issue 633504: cgi.py drops commandline arguments (original) (raw)

Created on 2002-11-04 21:51 by randallrandall, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (4)
msg13064 - (view) Author: Randall Randall (randallrandall) Date: 2002-11-04 21:51
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:
 216c216 <             continue --- >             else: nv.append('') 
This fix doesn't affect those using strictparsing=1 , which will still fail to include anything without an equals ('=').
msg13065 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-11-14 23:10
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?
msg13066 - (view) Author: Randall Randall (randallrandall) Date: 2002-11-15 16:00
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'
msg13067 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-11-15 16:48
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.
History
Date User Action Args
2022-04-10 16:05:48 admin set github: 37412
2002-11-04 21:51:12 randallrandall create