Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2....
File: cgi.py
#! /usr/bin/python2.7
[0] Fix | Delete
[1] Fix | Delete
# NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is
[2] Fix | Delete
# intentionally NOT "/usr/bin/env python". On many systems
[3] Fix | Delete
# (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI
[4] Fix | Delete
# scripts, and /usr/local/bin is the default directory where Python is
[5] Fix | Delete
# installed, so /usr/bin/env would be unable to find python. Granted,
[6] Fix | Delete
# binary installations by Linux vendors often install Python in
[7] Fix | Delete
# /usr/bin. So let those vendors patch cgi.py to match their choice
[8] Fix | Delete
# of installation.
[9] Fix | Delete
[10] Fix | Delete
"""Support module for CGI (Common Gateway Interface) scripts.
[11] Fix | Delete
[12] Fix | Delete
This module defines a number of utilities for use by CGI scripts
[13] Fix | Delete
written in Python.
[14] Fix | Delete
"""
[15] Fix | Delete
[16] Fix | Delete
# XXX Perhaps there should be a slimmed version that doesn't contain
[17] Fix | Delete
# all those backwards compatible and debugging classes and functions?
[18] Fix | Delete
[19] Fix | Delete
# History
[20] Fix | Delete
# -------
[21] Fix | Delete
#
[22] Fix | Delete
# Michael McLay started this module. Steve Majewski changed the
[23] Fix | Delete
# interface to SvFormContentDict and FormContentDict. The multipart
[24] Fix | Delete
# parsing was inspired by code submitted by Andreas Paepcke. Guido van
[25] Fix | Delete
# Rossum rewrote, reformatted and documented the module and is currently
[26] Fix | Delete
# responsible for its maintenance.
[27] Fix | Delete
#
[28] Fix | Delete
[29] Fix | Delete
__version__ = "2.6"
[30] Fix | Delete
[31] Fix | Delete
[32] Fix | Delete
# Imports
[33] Fix | Delete
# =======
[34] Fix | Delete
[35] Fix | Delete
from operator import attrgetter
[36] Fix | Delete
import sys
[37] Fix | Delete
import os
[38] Fix | Delete
import UserDict
[39] Fix | Delete
import urlparse
[40] Fix | Delete
[41] Fix | Delete
from warnings import filterwarnings, catch_warnings, warn
[42] Fix | Delete
with catch_warnings():
[43] Fix | Delete
if sys.py3kwarning:
[44] Fix | Delete
filterwarnings("ignore", ".*mimetools has been removed",
[45] Fix | Delete
DeprecationWarning)
[46] Fix | Delete
filterwarnings("ignore", ".*rfc822 has been removed",
[47] Fix | Delete
DeprecationWarning)
[48] Fix | Delete
import mimetools
[49] Fix | Delete
import rfc822
[50] Fix | Delete
[51] Fix | Delete
try:
[52] Fix | Delete
from cStringIO import StringIO
[53] Fix | Delete
except ImportError:
[54] Fix | Delete
from StringIO import StringIO
[55] Fix | Delete
[56] Fix | Delete
__all__ = ["MiniFieldStorage", "FieldStorage", "FormContentDict",
[57] Fix | Delete
"SvFormContentDict", "InterpFormContentDict", "FormContent",
[58] Fix | Delete
"parse", "parse_qs", "parse_qsl", "parse_multipart",
[59] Fix | Delete
"parse_header", "print_exception", "print_environ",
[60] Fix | Delete
"print_form", "print_directory", "print_arguments",
[61] Fix | Delete
"print_environ_usage", "escape"]
[62] Fix | Delete
[63] Fix | Delete
# Logging support
[64] Fix | Delete
# ===============
[65] Fix | Delete
[66] Fix | Delete
logfile = "" # Filename to log to, if not empty
[67] Fix | Delete
logfp = None # File object to log to, if not None
[68] Fix | Delete
[69] Fix | Delete
def initlog(*allargs):
[70] Fix | Delete
"""Write a log message, if there is a log file.
[71] Fix | Delete
[72] Fix | Delete
Even though this function is called initlog(), you should always
[73] Fix | Delete
use log(); log is a variable that is set either to initlog
[74] Fix | Delete
(initially), to dolog (once the log file has been opened), or to
[75] Fix | Delete
nolog (when logging is disabled).
[76] Fix | Delete
[77] Fix | Delete
The first argument is a format string; the remaining arguments (if
[78] Fix | Delete
any) are arguments to the % operator, so e.g.
[79] Fix | Delete
log("%s: %s", "a", "b")
[80] Fix | Delete
will write "a: b" to the log file, followed by a newline.
[81] Fix | Delete
[82] Fix | Delete
If the global logfp is not None, it should be a file object to
[83] Fix | Delete
which log data is written.
[84] Fix | Delete
[85] Fix | Delete
If the global logfp is None, the global logfile may be a string
[86] Fix | Delete
giving a filename to open, in append mode. This file should be
[87] Fix | Delete
world writable!!! If the file can't be opened, logging is
[88] Fix | Delete
silently disabled (since there is no safe place where we could
[89] Fix | Delete
send an error message).
[90] Fix | Delete
[91] Fix | Delete
"""
[92] Fix | Delete
global logfp, log
[93] Fix | Delete
if logfile and not logfp:
[94] Fix | Delete
try:
[95] Fix | Delete
logfp = open(logfile, "a")
[96] Fix | Delete
except IOError:
[97] Fix | Delete
pass
[98] Fix | Delete
if not logfp:
[99] Fix | Delete
log = nolog
[100] Fix | Delete
else:
[101] Fix | Delete
log = dolog
[102] Fix | Delete
log(*allargs)
[103] Fix | Delete
[104] Fix | Delete
def dolog(fmt, *args):
[105] Fix | Delete
"""Write a log message to the log file. See initlog() for docs."""
[106] Fix | Delete
logfp.write(fmt%args + "\n")
[107] Fix | Delete
[108] Fix | Delete
def nolog(*allargs):
[109] Fix | Delete
"""Dummy function, assigned to log when logging is disabled."""
[110] Fix | Delete
pass
[111] Fix | Delete
[112] Fix | Delete
log = initlog # The current logging function
[113] Fix | Delete
[114] Fix | Delete
[115] Fix | Delete
# Parsing functions
[116] Fix | Delete
# =================
[117] Fix | Delete
[118] Fix | Delete
# Maximum input we will accept when REQUEST_METHOD is POST
[119] Fix | Delete
# 0 ==> unlimited input
[120] Fix | Delete
maxlen = 0
[121] Fix | Delete
[122] Fix | Delete
def parse(fp=None, environ=os.environ, keep_blank_values=0,
[123] Fix | Delete
strict_parsing=0, separator=None):
[124] Fix | Delete
"""Parse a query in the environment or from a file (default stdin)
[125] Fix | Delete
[126] Fix | Delete
Arguments, all optional:
[127] Fix | Delete
[128] Fix | Delete
fp : file pointer; default: sys.stdin
[129] Fix | Delete
[130] Fix | Delete
environ : environment dictionary; default: os.environ
[131] Fix | Delete
[132] Fix | Delete
keep_blank_values: flag indicating whether blank values in
[133] Fix | Delete
percent-encoded forms should be treated as blank strings.
[134] Fix | Delete
A true value indicates that blanks should be retained as
[135] Fix | Delete
blank strings. The default false value indicates that
[136] Fix | Delete
blank values are to be ignored and treated as if they were
[137] Fix | Delete
not included.
[138] Fix | Delete
[139] Fix | Delete
strict_parsing: flag indicating what to do with parsing errors.
[140] Fix | Delete
If false (the default), errors are silently ignored.
[141] Fix | Delete
If true, errors raise a ValueError exception.
[142] Fix | Delete
[143] Fix | Delete
separator: str. The symbol to use for separating the query arguments.
[144] Fix | Delete
"""
[145] Fix | Delete
if fp is None:
[146] Fix | Delete
fp = sys.stdin
[147] Fix | Delete
if not 'REQUEST_METHOD' in environ:
[148] Fix | Delete
environ['REQUEST_METHOD'] = 'GET' # For testing stand-alone
[149] Fix | Delete
if environ['REQUEST_METHOD'] == 'POST':
[150] Fix | Delete
ctype, pdict = parse_header(environ['CONTENT_TYPE'])
[151] Fix | Delete
if ctype == 'multipart/form-data':
[152] Fix | Delete
return parse_multipart(fp, pdict)
[153] Fix | Delete
elif ctype == 'application/x-www-form-urlencoded':
[154] Fix | Delete
clength = int(environ['CONTENT_LENGTH'])
[155] Fix | Delete
if maxlen and clength > maxlen:
[156] Fix | Delete
raise ValueError, 'Maximum content length exceeded'
[157] Fix | Delete
qs = fp.read(clength)
[158] Fix | Delete
else:
[159] Fix | Delete
qs = '' # Unknown content-type
[160] Fix | Delete
if 'QUERY_STRING' in environ:
[161] Fix | Delete
if qs: qs = qs + '&'
[162] Fix | Delete
qs = qs + environ['QUERY_STRING']
[163] Fix | Delete
elif sys.argv[1:]:
[164] Fix | Delete
if qs: qs = qs + '&'
[165] Fix | Delete
qs = qs + sys.argv[1]
[166] Fix | Delete
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
[167] Fix | Delete
elif 'QUERY_STRING' in environ:
[168] Fix | Delete
qs = environ['QUERY_STRING']
[169] Fix | Delete
else:
[170] Fix | Delete
if sys.argv[1:]:
[171] Fix | Delete
qs = sys.argv[1]
[172] Fix | Delete
else:
[173] Fix | Delete
qs = ""
[174] Fix | Delete
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
[175] Fix | Delete
return urlparse.parse_qs(qs, keep_blank_values, strict_parsing, separator=separator)
[176] Fix | Delete
[177] Fix | Delete
[178] Fix | Delete
# parse query string function called from urlparse,
[179] Fix | Delete
# this is done in order to maintain backward compatibility.
[180] Fix | Delete
[181] Fix | Delete
def parse_qs(qs, keep_blank_values=0, strict_parsing=0, separator=None):
[182] Fix | Delete
"""Parse a query given as a string argument."""
[183] Fix | Delete
warn("cgi.parse_qs is deprecated, use urlparse.parse_qs instead",
[184] Fix | Delete
PendingDeprecationWarning, 2)
[185] Fix | Delete
return urlparse.parse_qs(qs, keep_blank_values, strict_parsing,
[186] Fix | Delete
separator=separator)
[187] Fix | Delete
[188] Fix | Delete
[189] Fix | Delete
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None, separator=None):
[190] Fix | Delete
"""Parse a query given as a string argument."""
[191] Fix | Delete
warn("cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead",
[192] Fix | Delete
PendingDeprecationWarning, 2)
[193] Fix | Delete
return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing,
[194] Fix | Delete
max_num_fields, separator=separator)
[195] Fix | Delete
[196] Fix | Delete
def parse_multipart(fp, pdict):
[197] Fix | Delete
"""Parse multipart input.
[198] Fix | Delete
[199] Fix | Delete
Arguments:
[200] Fix | Delete
fp : input file
[201] Fix | Delete
pdict: dictionary containing other parameters of content-type header
[202] Fix | Delete
[203] Fix | Delete
Returns a dictionary just like parse_qs(): keys are the field names, each
[204] Fix | Delete
value is a list of values for that field. This is easy to use but not
[205] Fix | Delete
much good if you are expecting megabytes to be uploaded -- in that case,
[206] Fix | Delete
use the FieldStorage class instead which is much more flexible. Note
[207] Fix | Delete
that content-type is the raw, unparsed contents of the content-type
[208] Fix | Delete
header.
[209] Fix | Delete
[210] Fix | Delete
XXX This does not parse nested multipart parts -- use FieldStorage for
[211] Fix | Delete
that.
[212] Fix | Delete
[213] Fix | Delete
XXX This should really be subsumed by FieldStorage altogether -- no
[214] Fix | Delete
point in having two implementations of the same parsing algorithm.
[215] Fix | Delete
Also, FieldStorage protects itself better against certain DoS attacks
[216] Fix | Delete
by limiting the size of the data read in one chunk. The API here
[217] Fix | Delete
does not support that kind of protection. This also affects parse()
[218] Fix | Delete
since it can call parse_multipart().
[219] Fix | Delete
[220] Fix | Delete
"""
[221] Fix | Delete
boundary = ""
[222] Fix | Delete
if 'boundary' in pdict:
[223] Fix | Delete
boundary = pdict['boundary']
[224] Fix | Delete
if not valid_boundary(boundary):
[225] Fix | Delete
raise ValueError, ('Invalid boundary in multipart form: %r'
[226] Fix | Delete
% (boundary,))
[227] Fix | Delete
[228] Fix | Delete
nextpart = "--" + boundary
[229] Fix | Delete
lastpart = "--" + boundary + "--"
[230] Fix | Delete
partdict = {}
[231] Fix | Delete
terminator = ""
[232] Fix | Delete
[233] Fix | Delete
while terminator != lastpart:
[234] Fix | Delete
bytes = -1
[235] Fix | Delete
data = None
[236] Fix | Delete
if terminator:
[237] Fix | Delete
# At start of next part. Read headers first.
[238] Fix | Delete
headers = mimetools.Message(fp)
[239] Fix | Delete
clength = headers.getheader('content-length')
[240] Fix | Delete
if clength:
[241] Fix | Delete
try:
[242] Fix | Delete
bytes = int(clength)
[243] Fix | Delete
except ValueError:
[244] Fix | Delete
pass
[245] Fix | Delete
if bytes > 0:
[246] Fix | Delete
if maxlen and bytes > maxlen:
[247] Fix | Delete
raise ValueError, 'Maximum content length exceeded'
[248] Fix | Delete
data = fp.read(bytes)
[249] Fix | Delete
else:
[250] Fix | Delete
data = ""
[251] Fix | Delete
# Read lines until end of part.
[252] Fix | Delete
lines = []
[253] Fix | Delete
while 1:
[254] Fix | Delete
line = fp.readline()
[255] Fix | Delete
if not line:
[256] Fix | Delete
terminator = lastpart # End outer loop
[257] Fix | Delete
break
[258] Fix | Delete
if line[:2] == "--":
[259] Fix | Delete
terminator = line.strip()
[260] Fix | Delete
if terminator in (nextpart, lastpart):
[261] Fix | Delete
break
[262] Fix | Delete
lines.append(line)
[263] Fix | Delete
# Done with part.
[264] Fix | Delete
if data is None:
[265] Fix | Delete
continue
[266] Fix | Delete
if bytes < 0:
[267] Fix | Delete
if lines:
[268] Fix | Delete
# Strip final line terminator
[269] Fix | Delete
line = lines[-1]
[270] Fix | Delete
if line[-2:] == "\r\n":
[271] Fix | Delete
line = line[:-2]
[272] Fix | Delete
elif line[-1:] == "\n":
[273] Fix | Delete
line = line[:-1]
[274] Fix | Delete
lines[-1] = line
[275] Fix | Delete
data = "".join(lines)
[276] Fix | Delete
line = headers['content-disposition']
[277] Fix | Delete
if not line:
[278] Fix | Delete
continue
[279] Fix | Delete
key, params = parse_header(line)
[280] Fix | Delete
if key != 'form-data':
[281] Fix | Delete
continue
[282] Fix | Delete
if 'name' in params:
[283] Fix | Delete
name = params['name']
[284] Fix | Delete
else:
[285] Fix | Delete
continue
[286] Fix | Delete
if name in partdict:
[287] Fix | Delete
partdict[name].append(data)
[288] Fix | Delete
else:
[289] Fix | Delete
partdict[name] = [data]
[290] Fix | Delete
[291] Fix | Delete
return partdict
[292] Fix | Delete
[293] Fix | Delete
def _parseparam(s):
[294] Fix | Delete
while s[:1] == ';':
[295] Fix | Delete
s = s[1:]
[296] Fix | Delete
end = s.find(';')
[297] Fix | Delete
while end > 0 and (s.count('"', 0, end) - s.count('\\"', 0, end)) % 2:
[298] Fix | Delete
end = s.find(';', end + 1)
[299] Fix | Delete
if end < 0:
[300] Fix | Delete
end = len(s)
[301] Fix | Delete
f = s[:end]
[302] Fix | Delete
yield f.strip()
[303] Fix | Delete
s = s[end:]
[304] Fix | Delete
[305] Fix | Delete
def parse_header(line):
[306] Fix | Delete
"""Parse a Content-type like header.
[307] Fix | Delete
[308] Fix | Delete
Return the main content-type and a dictionary of options.
[309] Fix | Delete
[310] Fix | Delete
"""
[311] Fix | Delete
parts = _parseparam(';' + line)
[312] Fix | Delete
key = parts.next()
[313] Fix | Delete
pdict = {}
[314] Fix | Delete
for p in parts:
[315] Fix | Delete
i = p.find('=')
[316] Fix | Delete
if i >= 0:
[317] Fix | Delete
name = p[:i].strip().lower()
[318] Fix | Delete
value = p[i+1:].strip()
[319] Fix | Delete
if len(value) >= 2 and value[0] == value[-1] == '"':
[320] Fix | Delete
value = value[1:-1]
[321] Fix | Delete
value = value.replace('\\\\', '\\').replace('\\"', '"')
[322] Fix | Delete
pdict[name] = value
[323] Fix | Delete
return key, pdict
[324] Fix | Delete
[325] Fix | Delete
[326] Fix | Delete
# Classes for field storage
[327] Fix | Delete
# =========================
[328] Fix | Delete
[329] Fix | Delete
class MiniFieldStorage:
[330] Fix | Delete
[331] Fix | Delete
"""Like FieldStorage, for use when no file uploads are possible."""
[332] Fix | Delete
[333] Fix | Delete
# Dummy attributes
[334] Fix | Delete
filename = None
[335] Fix | Delete
list = None
[336] Fix | Delete
type = None
[337] Fix | Delete
file = None
[338] Fix | Delete
type_options = {}
[339] Fix | Delete
disposition = None
[340] Fix | Delete
disposition_options = {}
[341] Fix | Delete
headers = {}
[342] Fix | Delete
[343] Fix | Delete
def __init__(self, name, value):
[344] Fix | Delete
"""Constructor from field name and value."""
[345] Fix | Delete
self.name = name
[346] Fix | Delete
self.value = value
[347] Fix | Delete
# self.file = StringIO(value)
[348] Fix | Delete
[349] Fix | Delete
def __repr__(self):
[350] Fix | Delete
"""Return printable representation."""
[351] Fix | Delete
return "MiniFieldStorage(%r, %r)" % (self.name, self.value)
[352] Fix | Delete
[353] Fix | Delete
[354] Fix | Delete
class FieldStorage:
[355] Fix | Delete
[356] Fix | Delete
"""Store a sequence of fields, reading multipart/form-data.
[357] Fix | Delete
[358] Fix | Delete
This class provides naming, typing, files stored on disk, and
[359] Fix | Delete
more. At the top level, it is accessible like a dictionary, whose
[360] Fix | Delete
keys are the field names. (Note: None can occur as a field name.)
[361] Fix | Delete
The items are either a Python list (if there's multiple values) or
[362] Fix | Delete
another FieldStorage or MiniFieldStorage object. If it's a single
[363] Fix | Delete
object, it has the following attributes:
[364] Fix | Delete
[365] Fix | Delete
name: the field name, if specified; otherwise None
[366] Fix | Delete
[367] Fix | Delete
filename: the filename, if specified; otherwise None; this is the
[368] Fix | Delete
client side filename, *not* the file name on which it is
[369] Fix | Delete
stored (that's a temporary file you don't deal with)
[370] Fix | Delete
[371] Fix | Delete
value: the value as a *string*; for file uploads, this
[372] Fix | Delete
transparently reads the file every time you request the value
[373] Fix | Delete
[374] Fix | Delete
file: the file(-like) object from which you can read the data;
[375] Fix | Delete
None if the data is stored a simple string
[376] Fix | Delete
[377] Fix | Delete
type: the content-type, or None if not specified
[378] Fix | Delete
[379] Fix | Delete
type_options: dictionary of options specified on the content-type
[380] Fix | Delete
line
[381] Fix | Delete
[382] Fix | Delete
disposition: content-disposition, or None if not specified
[383] Fix | Delete
[384] Fix | Delete
disposition_options: dictionary of corresponding options
[385] Fix | Delete
[386] Fix | Delete
headers: a dictionary(-like) object (sometimes rfc822.Message or a
[387] Fix | Delete
subclass thereof) containing *all* headers
[388] Fix | Delete
[389] Fix | Delete
The class is subclassable, mostly for the purpose of overriding
[390] Fix | Delete
the make_file() method, which is called internally to come up with
[391] Fix | Delete
a file open for reading and writing. This makes it possible to
[392] Fix | Delete
override the default choice of storing all files in a temporary
[393] Fix | Delete
directory and unlinking them as soon as they have been opened.
[394] Fix | Delete
[395] Fix | Delete
"""
[396] Fix | Delete
[397] Fix | Delete
def __init__(self, fp=None, headers=None, outerboundary="",
[398] Fix | Delete
environ=os.environ, keep_blank_values=0, strict_parsing=0,
[399] Fix | Delete
max_num_fields=None, separator=None):
[400] Fix | Delete
"""Constructor. Read multipart/* until last part.
[401] Fix | Delete
[402] Fix | Delete
Arguments, all optional:
[403] Fix | Delete
[404] Fix | Delete
fp : file pointer; default: sys.stdin
[405] Fix | Delete
(not used when the request method is GET)
[406] Fix | Delete
[407] Fix | Delete
headers : header dictionary-like object; default:
[408] Fix | Delete
taken from environ as per CGI spec
[409] Fix | Delete
[410] Fix | Delete
outerboundary : terminating multipart boundary
[411] Fix | Delete
(for internal use only)
[412] Fix | Delete
[413] Fix | Delete
environ : environment dictionary; default: os.environ
[414] Fix | Delete
[415] Fix | Delete
keep_blank_values: flag indicating whether blank values in
[416] Fix | Delete
percent-encoded forms should be treated as blank strings.
[417] Fix | Delete
A true value indicates that blanks should be retained as
[418] Fix | Delete
blank strings. The default false value indicates that
[419] Fix | Delete
blank values are to be ignored and treated as if they were
[420] Fix | Delete
not included.
[421] Fix | Delete
[422] Fix | Delete
strict_parsing: flag indicating what to do with parsing errors.
[423] Fix | Delete
If false (the default), errors are silently ignored.
[424] Fix | Delete
If true, errors raise a ValueError exception.
[425] Fix | Delete
[426] Fix | Delete
max_num_fields: int. If set, then __init__ throws a ValueError
[427] Fix | Delete
if there are more than n fields read by parse_qsl().
[428] Fix | Delete
[429] Fix | Delete
"""
[430] Fix | Delete
method = 'GET'
[431] Fix | Delete
self.keep_blank_values = keep_blank_values
[432] Fix | Delete
self.strict_parsing = strict_parsing
[433] Fix | Delete
self.max_num_fields = max_num_fields
[434] Fix | Delete
self.separator = separator
[435] Fix | Delete
if 'REQUEST_METHOD' in environ:
[436] Fix | Delete
method = environ['REQUEST_METHOD'].upper()
[437] Fix | Delete
self.qs_on_post = None
[438] Fix | Delete
if method == 'GET' or method == 'HEAD':
[439] Fix | Delete
if 'QUERY_STRING' in environ:
[440] Fix | Delete
qs = environ['QUERY_STRING']
[441] Fix | Delete
elif sys.argv[1:]:
[442] Fix | Delete
qs = sys.argv[1]
[443] Fix | Delete
else:
[444] Fix | Delete
qs = ""
[445] Fix | Delete
fp = StringIO(qs)
[446] Fix | Delete
if headers is None:
[447] Fix | Delete
headers = {'content-type':
[448] Fix | Delete
"application/x-www-form-urlencoded"}
[449] Fix | Delete
if headers is None:
[450] Fix | Delete
headers = {}
[451] Fix | Delete
if method == 'POST':
[452] Fix | Delete
# Set default content-type for POST to what's traditional
[453] Fix | Delete
headers['content-type'] = "application/x-www-form-urlencoded"
[454] Fix | Delete
if 'CONTENT_TYPE' in environ:
[455] Fix | Delete
headers['content-type'] = environ['CONTENT_TYPE']
[456] Fix | Delete
if 'QUERY_STRING' in environ:
[457] Fix | Delete
self.qs_on_post = environ['QUERY_STRING']
[458] Fix | Delete
if 'CONTENT_LENGTH' in environ:
[459] Fix | Delete
headers['content-length'] = environ['CONTENT_LENGTH']
[460] Fix | Delete
self.fp = fp or sys.stdin
[461] Fix | Delete
self.headers = headers
[462] Fix | Delete
self.outerboundary = outerboundary
[463] Fix | Delete
[464] Fix | Delete
# Process content-disposition header
[465] Fix | Delete
cdisp, pdict = "", {}
[466] Fix | Delete
if 'content-disposition' in self.headers:
[467] Fix | Delete
cdisp, pdict = parse_header(self.headers['content-disposition'])
[468] Fix | Delete
self.disposition = cdisp
[469] Fix | Delete
self.disposition_options = pdict
[470] Fix | Delete
self.name = None
[471] Fix | Delete
if 'name' in pdict:
[472] Fix | Delete
self.name = pdict['name']
[473] Fix | Delete
self.filename = None
[474] Fix | Delete
if 'filename' in pdict:
[475] Fix | Delete
self.filename = pdict['filename']
[476] Fix | Delete
[477] Fix | Delete
# Process content-type header
[478] Fix | Delete
#
[479] Fix | Delete
# Honor any existing content-type header. But if there is no
[480] Fix | Delete
# content-type header, use some sensible defaults. Assume
[481] Fix | Delete
# outerboundary is "" at the outer level, but something non-false
[482] Fix | Delete
# inside a multi-part. The default for an inner part is text/plain,
[483] Fix | Delete
# but for an outer part it should be urlencoded. This should catch
[484] Fix | Delete
# bogus clients which erroneously forget to include a content-type
[485] Fix | Delete
# header.
[486] Fix | Delete
#
[487] Fix | Delete
# See below for what we do if there does exist a content-type header,
[488] Fix | Delete
# but it happens to be something we don't understand.
[489] Fix | Delete
if 'content-type' in self.headers:
[490] Fix | Delete
ctype, pdict = parse_header(self.headers['content-type'])
[491] Fix | Delete
elif self.outerboundary or method != 'POST':
[492] Fix | Delete
ctype, pdict = "text/plain", {}
[493] Fix | Delete
else:
[494] Fix | Delete
ctype, pdict = 'application/x-www-form-urlencoded', {}
[495] Fix | Delete
self.type = ctype
[496] Fix | Delete
self.type_options = pdict
[497] Fix | Delete
self.innerboundary = ""
[498] Fix | Delete
if 'boundary' in pdict:
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function