diff --git a/mbox2web b/mbox2web index e95fabf..3f7c130 100755 --- a/mbox2web +++ b/mbox2web @@ -131,9 +131,25 @@ def render_body(msg, extra=None): if type(parts) == str: # mislabelled, assume text/plain return render_text_plain(msg) + # First, scan for parts with a content-id. A multipart/mixed shouldn't + # have them, but I've seen them in the wild and it should be harmless + # to support at least images. We don't want all content types, though, + # because save_part doesn't support nested parts and I don't want to + # fully implement what is really just a workaround for buggy software. + for i, part in enumerate(msg.get_payload()): + content_id = part.get("Content-Id") + content_type = part.get_content_type() + if content_id and content_type.startswith("image/"): + if extra is None: + extra = {} + extra[content_id] = { + "i": i, + "part": part, + "url": save_part(part, "_url"), + } partshtml = [] for part in msg.get_payload(): - partshtml.append(render_body(part)) + partshtml.append(render_body(part, extra)) bodytmpl = jenv.get_template("body_multipart_mixed.html") context = { "parts": partshtml