summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-06-21 18:58:04 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-06-21 18:58:04 (GMT)
commita6a4d50efe7dca189e1c89ba38db4e0e1f5a68dd (patch)
tree03913e97c5b033f1b8b36ff67f28b0c409bbe2e0 /Lib/cgi.py
parent2da91c375b095a452dd1e81962983e89e3fd0d07 (diff)
downloadcpython-a6a4d50efe7dca189e1c89ba38db4e0e1f5a68dd.zip
cpython-a6a4d50efe7dca189e1c89ba38db4e0e1f5a68dd.tar.gz
cpython-a6a4d50efe7dca189e1c89ba38db4e0e1f5a68dd.tar.bz2
Now a from submitted via POST that also has a query string
will contain both FieldStorage and MiniFieldStorage items. Fixes #1817.
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 8760f96..561f5ad 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -456,6 +456,7 @@ class FieldStorage:
self.strict_parsing = strict_parsing
if 'REQUEST_METHOD' in environ:
method = environ['REQUEST_METHOD'].upper()
+ self.qs_on_post = None
if method == 'GET' or method == 'HEAD':
if 'QUERY_STRING' in environ:
qs = environ['QUERY_STRING']
@@ -474,6 +475,8 @@ class FieldStorage:
headers['content-type'] = "application/x-www-form-urlencoded"
if 'CONTENT_TYPE' in environ:
headers['content-type'] = environ['CONTENT_TYPE']
+ if 'QUERY_STRING' in environ:
+ self.qs_on_post = environ['QUERY_STRING']
if 'CONTENT_LENGTH' in environ:
headers['content-length'] = environ['CONTENT_LENGTH']
self.fp = fp or sys.stdin
@@ -631,6 +634,8 @@ class FieldStorage:
def read_urlencoded(self):
"""Internal: read data in query string format."""
qs = self.fp.read(self.length)
+ if self.qs_on_post:
+ qs += '&' + self.qs_on_post
self.list = list = []
for key, value in parse_qsl(qs, self.keep_blank_values,
self.strict_parsing):
@@ -645,6 +650,12 @@ class FieldStorage:
if not valid_boundary(ib):
raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
self.list = []
+ if self.qs_on_post:
+ for key, value in parse_qsl(self.qs_on_post, self.keep_blank_values,
+ self.strict_parsing):
+ self.list.append(MiniFieldStorage(key, value))
+ FieldStorageClass = None
+
klass = self.FieldStorageClass or self.__class__
part = klass(self.fp, {}, ib,
environ, keep_blank_values, strict_parsing)