X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=mimedecode.py;h=d239a1fe2234e332cb78b7d96387c687c98c6e70;hb=f0f753ad009f6bd7089e0d6d3fce3ffd111734f5;hp=6567e9926b562e0c7504cdd849c3ba183f447eba;hpb=0d46ae8e42cfae5ba8d3c5838dc4f5bca57130bf;p=mimedecode.git diff --git a/mimedecode.py b/mimedecode.py index 6567e99..d239a1f 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -377,6 +377,26 @@ def decode_multipart(msg): "Decode multipart" decode_headers(msg) + boundary = msg.get_boundary() + + masks = [] + ctype = msg.get_content_type() + if ctype: + masks.append(ctype) + mtype = ctype.split('/')[0] + masks.append(mtype + '/*') + masks.append('*/*') + + for content_type in masks: + if content_type in g.ignore_mask: + output_headers(msg) + output("%sMessage body of type %s skipped.%s" % (os.linesep, ctype, os.linesep)) + if boundary: + output("%s--%s--%s" % (os.linesep, boundary, os.linesep)) + return + elif content_type in g.error_mask: + raise ValueError, "content type %s prohibited" % ctype + output_headers(msg) if msg.preamble: # Preserve the first part, it is probably not a RFC822-message @@ -385,8 +405,6 @@ def decode_multipart(msg): output(os.linesep) first_subpart = True - boundary = msg.get_boundary() - for subpart in msg.get_payload(): if boundary: if first_subpart: