Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce900de

Browse files
committed
At Jim Fulton's request (actually, as a compromise :-), default the
content-type to application/x-www-form-urlencoded only when the method is POST. Ditto for when the content-type is unrecognized -- only fall back to urlencoded with POST.
1 parent 094189f commit ce900de

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/cgi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def __init__(self, fp=None, headers=None, outerboundary="",
841841
# but it happens to be something we don't understand.
842842
if self.headers.has_key('content-type'):
843843
ctype, pdict = parse_header(self.headers['content-type'])
844-
elif self.outerboundary:
844+
elif self.outerboundary or method != 'POST':
845845
ctype, pdict = "text/plain", {}
846846
else:
847847
ctype, pdict = 'application/x-www-form-urlencoded', {}
@@ -867,7 +867,7 @@ def __init__(self, fp=None, headers=None, outerboundary="",
867867
self.read_urlencoded()
868868
elif ctype[:10] == 'multipart/':
869869
self.read_multi(environ, keep_blank_values, strict_parsing)
870-
elif self.outerboundary:
870+
elif self.outerboundary or method != 'POST':
871871
# we're in an inner part, but the content-type wasn't something we
872872
# understood. default to read_single() because the resulting
873873
# FieldStorage won't be a mapping (and doesn't need to be).

0 commit comments

Comments
 (0)