X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=mimedecode.py;h=5bd045bc59b3834936e60f6282ac978f506f3420;hb=0016b6d98205a44dbf01d8a48304244bbd7bfb0e;hp=8d50b7d0d56453ab0d148cc0d66311c2d6b13081;hpb=97bb61c949daa07f87cf4b72391496a94120dc95;p=mimedecode.git diff --git a/mimedecode.py b/mimedecode.py index 8d50b7d..5bd045b 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -398,7 +398,35 @@ def decode_multipart(msg): if boundary: output("%s--%s--%s" % (os.linesep, boundary, os.linesep)) return - elif content_type in g.error_mask: + + for content_type in masks: + if content_type in g.save_body_mask or \ + content_type in g.save_message_mask: + _out_l = [] + first_subpart = True + for subpart in msg.get_payload(): + if first_subpart: + first_subpart = False + else: + _out_l.append(os.linesep) + _out_l.append("--%s%s" % (boundary, os.linesep)) + _out_l.append(subpart.as_string()) + _out_l.append("%s--%s--%s" % (os.linesep, boundary, os.linesep)) + outstring = ''.join(_out_l) + break + else: + outstring = None + + for content_type in masks: + if content_type in g.save_headers_mask: + _save_message(msg, outstring, save_headers=True, save_body=False) + if content_type in g.save_body_mask: + _save_message(msg, outstring, save_headers=False, save_body=True) + if content_type in g.save_message_mask: + _save_message(msg, outstring, save_headers=True, save_body=True) + + for content_type in masks: + if content_type in g.error_mask: raise ValueError, "content type %s prohibited" % ctype output_headers(msg)