Skip to content
Snippets Groups Projects
Commit 1ee2451e authored by Jani Nikula's avatar Jani Nikula
Browse files

dim: fix message_print_body() for complex multipart messages

Commit e9846737 ("dim: Dumbest base64 parser ever for apply-pull")
broke dim apply-pull for complex multipart messages, such as [1] with
mime structure:

└┬╴multipart/mixed 11398 bytes
 ├┬╴multipart/signed inline 2051 bytes
 │├─╴text/plain inline 1470 bytes
 │└─╴application/pgp-signature [signature.asc] 195 bytes
 └─╴text/plain inline 219 bytes

The problem lies in the original message_print_body() which would not
recurse beyond the first multipart nesting level. Use the message walk()
function to also find the text/plain part within the multipart/signed
part.

[1] http://mid.mail-archive.com/20190117074604.GI18272@zhen-hp.sh.intel.com



v2: only print text/plain (Daniel)

Fixes: f9bd24c2 ("dim: Add extract-tags command")
Fixes: e9846737 ("dim: Dumbest base64 parser ever for apply-pull")
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 1df43927
No related branches found
No related tags found
No related merge requests found
Pipeline #15324 failed
......@@ -432,18 +432,11 @@ message_print_body ()
python2 <<EOF
import email
def print_part(part):
mtype = part.get_content_maintype()
if mtype == 'text':
print(part.get_payload(decode=True))
def print_msg(file):
msg = email.message_from_file(file)
if msg.is_multipart():
for part in msg.get_payload():
print_part(part)
else:
print_part(msg)
for part in msg.walk():
if part.get_content_type() == 'text/plain':
print(part.get_payload(decode=True))
print_msg(open('$1', 'r'))
EOF
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment