python / cpython

The Python programming language
https://www.python.org
Other
63.17k stars 30.25k forks source link

cgi.parse_multipart is not consistent with FieldStorage #74165

Closed 006d7b03-f9f3-44da-bb8d-8d7a3e15fee9 closed 7 years ago

006d7b03-f9f3-44da-bb8d-8d7a3e15fee9 commented 7 years ago
BPO 29979
Nosy @orsenthil, @PierreQuentel, @vadmium
PRs
  • python/cpython#990
  • python/cpython#991
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = 'https://github.com/orsenthil' closed_at = created_at = labels = ['3.7', 'type-bug', 'library'] title = 'cgi.parse_multipart is not consistent with FieldStorage' updated_at = user = 'https://github.com/PierreQuentel' ``` bugs.python.org fields: ```python activity = actor = 'martin.panter' assignee = 'orsenthil' closed = True closed_date = closer = 'orsenthil' components = ['Library (Lib)'] creation = creator = 'quentel' dependencies = [] files = [] hgrepos = [] issue_num = 29979 keywords = [] message_count = 4.0 messages = ['291117', '291122', '291491', '293233'] nosy_count = 3.0 nosy_names = ['orsenthil', 'quentel', 'martin.panter'] pr_nums = ['990', '991'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue29979' versions = ['Python 3.7'] ```

    006d7b03-f9f3-44da-bb8d-8d7a3e15fee9 commented 7 years ago

    In the cgi module, the parse_multipart() function duplicates code from FieldStorage, and the result is not compliant with that of FieldStorage for requests sent with multipart/form-data : for non-file fields, the value associated with a key is a list of *bytes in parse_multipart() and a list of *strings for FieldStorage (the bytes decoded with the argument "encoding" passed to FieldStorage()).

    I will propose a PR on the Github repo with a version of parse_multipart that uses FieldStorage and returns the same result (values as strings). The function will take an additional argument "encoding".

    orsenthil commented 7 years ago

    Looking forward to this.

    006d7b03-f9f3-44da-bb8d-8d7a3e15fee9 commented 7 years ago

    Senthil,

    Can you take a look at the Pull Request when you have time ? The correct PR is #991, not #990.

    orsenthil commented 7 years ago

    New changeset cc3fa204d357be5fafc10eb8c2a80fe0bca998f1 by Senthil Kumaran (Pierre Quentel) in branch 'master': bpo-29979: Rewrite cgi.parse_multipart to make it consistent with FieldStorage (#991) https://github.com/python/cpython/commit/cc3fa204d357be5fafc10eb8c2a80fe0bca998f1