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.Parser does not recognize attachment
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, mamuema
Priority: normal Keywords:

Created on 2004-11-05 13:30 by mamuema, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
simpletest.py mamuema, 2004-11-05 13:30 script demonstrating the problem
Messages (2)
msg23023 - (view) Author: Martin Muenstermann (mamuema) Date: 2004-11-05 13:30
Python Version: 2.3.4
I received an email with attachment, whose sender chose
a boundary starting with a whitespace (' '). 
Problem: email.Parser does not recognize the
attachment, msg.is_multipart() returns False,
msg.walk() returns the whole mail as one part.

The problem seems to be caused by the fact that the
implementation of msg.get_boundary() calls strip().

Problem can be reproduced with the attached script.
Output for me is:
msg.get_content_maintype(): multipart
msg.is_multipart():         False
msg.get_boundary():         'simple boundary'
msg.get_param('boundary'):  ' simple boundary'

I don't know if this boundary is legal according to the
RFCs, but maybe we should handle it anyway?

Regards,
 Martin
msg23024 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-11-06 00:04
Logged In: YES 
user_id=12800

RFC 2046 does not allow boundaries to end with whitespace,
but it does allow them to begin with whitespace.  You're
right that the bug is in get_boundary() -- that should
rstrip the value.  I don't think we should support
boundaries that end in whitespace, but I will fix this for
Python 2.3 and 2.4.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41127
2004-11-05 13:30:56mamuemacreate