This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cgi: parse_qs and parse_qsl misbehave on empty strings
Type: behavior Stage:
Components: Extension Modules Versions: Python 2.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: dljessup, gvanrossum, nirs, orsenthil
Priority: normal Keywords:

Created on 2007-08-24 20:54 by dljessup, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg55274 - (view) Author: David Jessup (dljessup) Date: 2007-08-24 20:54
In Python 2.4.4, cgi.parse_qs(qs='', strict_parsing=True) errors out:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/cgi.py", line 183, in parse_qs
    for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):
  File "/usr/lib/python2.4/cgi.py", line 217, in parse_qsl
    raise ValueError, "bad query field: %r" % (name_value,)
ValueError: bad query field: ''

To the best of my knowledge, this is bad behavior, since a large
percentage of URLs actually used have empty query strings.
msg55309 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2007-08-26 17:49
Can query strings be empty? I am unable to find an instance.
msg55727 - (view) Author: Nir Soffer (nirs) * Date: 2007-09-07 02:11
Here is one: http://example.com/foo?
msg55728 - (view) Author: Nir Soffer (nirs) * Date: 2007-09-07 02:14
Addionally, if the default value is empty string, you expect it work with 
empty string. If a non empty value is needed, it would use None as the 
default.
msg55977 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2007-09-17 20:32
Hi Sean,
This is a very minor issue (IMO) with Python 2.4. Why did you assign it
to gvanrossum?

Makes me wonder at your assignments.

Thanks,
Senthil
msg55983 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-09-17 21:15
I don't see what the problem is.  You requested strict_parsing=True, and
this is what strict parsing does.
History
Date User Action Args
2022-04-11 14:56:26adminsetgithub: 45355
2007-09-17 21:15:48gvanrossumsetstatus: open -> closed
resolution: wont fix
messages: + msg55983
2007-09-17 20:32:35orsenthilsetmessages: + msg55977
2007-09-17 08:38:08jafosetpriority: normal
assignee: gvanrossum
nosy: + gvanrossum
2007-09-07 02:14:24nirssetmessages: + msg55728
2007-09-07 02:11:29nirssetnosy: + nirs
messages: + msg55727
2007-08-26 17:49:52orsenthilsetnosy: + orsenthil
messages: + msg55309
2007-08-24 20:54:35dljessupcreate