Gateway: Revert non-gzip form encoded check

Fixes the regression identified in #165

However the gzip code path can still erroneously think a decompressed
request body is form encoded when it is not.  This happens when any text
in the decompressed body matches the regex:

        .+=[^\&;]*

i.e. some text, followed by `=`, and then some more text, possibly
empty, followed by an ampersand `&`, or semi-colon `;`, or the end of the
string.

`&` and `;` are used to separate key=value pairs in form encoding, the
`=` separates a key from its value.
This commit is contained in:
Athanasius 2022-01-11 15:06:02 +00:00
parent 6add1d5c6b
commit abcf472197

View File

@ -166,23 +166,13 @@ def get_decompressed_message():
else:
logger.debug('Content-Encoding indicates *not* compressed...')
form_enc_parsed = urlparse.parse_qs(request.body.read())
if form_enc_parsed:
logger.debug('Request is form-encoded')
# Uncompressed request. Bottle handles all of the parsing of the
# POST key/vals, or un-encoded body.
data_key = request.forms.get('data')
if data_key:
logger.debug('form-encoded POST request detected...')
# This is a form-encoded POST. Support the silly people.
message_body = data_key
else:
raise MalformedUploadError(
"No 'data' POST key/value found. Check your POST key "
"name for spelling, and make sure you're passing a value."
)
# Uncompressed request. Bottle handles all of the parsing of the
# POST key/vals, or un-encoded body.
data_key = request.forms.get('data')
if data_key:
logger.debug('form-encoded POST request detected...')
# This is a form-encoded POST. Support the silly people.
message_body = data_key
else:
logger.debug('Plain POST request detected...')