_create_forward_message fixed for multipart messages
This commit is contained in:
parent
046111e267
commit
406cce6270
|
|
@ -272,13 +272,22 @@ class RulesProcessor:
|
||||||
|
|
||||||
msg.attach(body_part)
|
msg.attach(body_part)
|
||||||
|
|
||||||
# Copy attachments
|
# Copy attachments - FIX FILENAMES
|
||||||
if original_parsed.is_multipart():
|
if original_parsed.is_multipart():
|
||||||
for part in original_parsed.walk():
|
for part in original_parsed.walk():
|
||||||
if part.get_content_maintype() == 'multipart':
|
if part.get_content_maintype() == 'multipart':
|
||||||
continue
|
continue
|
||||||
if part.get_content_type() in ['text/plain', 'text/html']:
|
if part.get_content_type() in ['text/plain', 'text/html']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Fix malformed filename in Content-Disposition
|
||||||
|
content_disp = part.get('Content-Disposition', '')
|
||||||
|
if 'filename=' in content_disp and '"' not in content_disp:
|
||||||
|
# Add quotes around filename with spaces
|
||||||
|
import re
|
||||||
|
fixed_disp = re.sub(r'filename=([^;"\s]+(?:\s+[^;"\s]+)*)', r'filename="\1"', content_disp)
|
||||||
|
part.replace_header('Content-Disposition', fixed_disp)
|
||||||
|
|
||||||
msg.attach(part)
|
msg.attach(part)
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue