[issue24764] cgi.FieldStorage can't parse multipart part headers with Content-Length and no filename in Content-Disposition

Peter Landry report at bugs.python.org
Fri Jul 31 18:08:47 CEST 2015


Peter Landry added the comment:

I realized my formatting was poor, making it hard to quickly test the issue. Here's a cleaner version:

    import cgi
    from io import BytesIO

    BOUNDARY = "JfISa01"
    POSTDATA = """--JfISa01
    Content-Disposition: form-data; name="submit-name"
    Content-Length: 5

    Larry
    --JfISa01"""
    env = {
        'REQUEST_METHOD': 'POST',
        'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
        'CONTENT_LENGTH': str(len(POSTDATA))}
    fp = BytesIO(POSTDATA.encode('latin-1'))
    fs = cgi.FieldStorage(fp, environ=env, encoding="latin-1")

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24764>
_______________________________________


More information about the Python-bugs-list mailing list