This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: email.Utils.py: "'" in RFC2231 header
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, tkikuchi
Priority: normal Keywords:

Created on 2005-06-10 10:07 by tkikuchi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg25520 - (view) Author: Tokio Kikuchi (tkikuchi) Date: 2005-06-10 10:07
A header like this one can cause ValueError in
attempting to decode the RFC2231 format:

Content-Disposition: inline;
        filename*0="Today's Headlines- C.I.A. Is
Reviewing Its Security Policy
        for R"; filename*1="ecruiting Translators.jpg"

Note that there is a ' in the filename.  MUA should
have escaped the ' by %27 but Python email library
should be robust for such a violation.

Here is the traceback:

>>> print p[4]['content-disposition']
inline;
        filename*0="Today's Headlines- C.I.A. Is
Reviewing Its Security Policy
        for R"; filename*1="ecruiting Translators.jpg"
>>> p[4].get_filename()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.4/email/Message.py",
line 707, in get_filename
    filename = self.get_param('filename', missing,
'content-disposition')
  File "/usr/local/lib/python2.4/email/Message.py",
line 590, in get_param
    for k, v in self._get_params_preserve(failobj, header):
  File "/usr/local/lib/python2.4/email/Message.py",
line 537, in _get_params_pre
serve
    params = Utils.decode_params(params)
  File "/usr/local/lib/python2.4/email/Utils.py", line
275, in decode_params
    charset, language, value =
decode_rfc2231(EMPTYSTRING.join(value))
  File "/usr/local/lib/python2.4/email/Utils.py", line
222, in decode_rfc2231
    charset, language, s = parts
ValueError: need more than 2 values to unpack
>>>
msg25521 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2006-07-17 23:08
Logged In: YES 
user_id=12800

Fixed in r50692 in the Python 2.5 trunk.  I will back port
these changes to email 3.0 and 2.5.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42070
2005-06-10 10:07:39tkikuchicreate