python / cpython

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

Incorrect RFC 2231 decoding #41444

Closed warsaw closed 9 years ago

warsaw commented 19 years ago
BPO 1102973
Nosy @warsaw, @raulcd

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/warsaw' closed_at = created_at = labels = ['library'] title = 'Incorrect RFC 2231 decoding' updated_at = user = 'https://github.com/warsaw' ``` bugs.python.org fields: ```python activity = actor = 'raulcd' assignee = 'barry' closed = True closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'barry' dependencies = [] files = [] hgrepos = [] issue_num = 1102973 keywords = [] message_count = 1.0 messages = ['23973'] nosy_count = 2.0 nosy_names = ['barry', 'raulcd'] pr_nums = [] priority = 'normal' resolution = 'duplicate' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue1102973' versions = ['Python 2.4'] ```

warsaw commented 19 years ago

The following message

---snip snip--- Content-Transfer-Encoding: base64 Content-Type: application/msword; x-mac-type=42494E41; x-unix-mode=0644; x-mac-creator=4D535744; name="miriam's file.doc" Content-Disposition: attachment; filename*0="miriam's file"; filename*1=ths.doc ---snip snip---

Is incorrectly decoded according to RFC 2231. The bug is in Utils.py in the decode_params() and decode_rfc2231() functions. charset/lang encoding should only be present on the first parameter, i.e. filename*0 and even then, the quoted single quote should not trip up the scanner. The problem is two fold:

I've labeled this in the Group: Python 2.4, but it really affects Python 2.3 as well, and the current head.