parts ("attachments") all parts are decoded. Decoding can be controlled by
command-line options.
+WHAT'S NEW in version 2.3.8 (2014-02-26)
+
+ Add option --remove-params=header to remove all parameters from the header.
+
WHAT'S NEW in version 2.3.7 (2014-02-23)
Add option -r to remove headers and option -R to remove header's parameters.
Recommends: configured mailcap database.
- Documentation (also included in the package):
- http://phdru.name/Software/Python/mimedecode.txt
-
+ Documentation: http://phdru.name/Software/Python/mimedecode.txt
+ (also included in the package in the html and man formats):
AUTHOR
Oleg Broytman <phd@phdru.name>
<arg choice="opt">
<option>-R header:param</option>
</arg>
+ <arg choice="opt">
+ <option>--remove-params=header</option>
+ </arg>
<arg choice="opt">
<option>-beit mask</option>
</arg>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>--remove-params=header</term>
+ <listitem>
+ <para>
+ Add the header to a list of headers from which all parameters will
+ be removed; initially the list is empty.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-b mask</term>
<listitem>
def usage(code=0, errormsg=''):
version(0)
sys.stdout.write("""\
-Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header] [-p header:param] [-r header] [-R header:param] [-beit mask] [-o output_file] [input_file [output_file]]
+Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header] [-p header:param] [-r header] [-R header:param] [--remove-params=header] [-beit mask] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
sys.stderr.write(errormsg + '\n')
for header in gopts.remove_headers:
del msg[header]
+ for header in gopts.remove_all_params:
+ value = msg[header]
+ if value is None:
+ continue
+ if ';' not in value:
+ continue
+ del msg[header]
+ msg[header] = value.split(';')[0].strip()
+
for header, param in gopts.remove_header_params:
msg.del_param(param, header)
remove_headers = []
# A list of headers parameters to remove
remove_header_params = []
+ # A list of headers to be stripped of all parameters
+ remove_all_params = []
totext_mask = [] # A list of content-types to decode
binary_mask = [] # A list to pass through
try:
options, arguments = getopt(sys.argv[1:],
'hVcCDPH:f:d:p:r:R:b:e:i:t:o:',
- ['help', 'version', 'host'])
+ ['help', 'version', 'host=', 'remove-params='])
except GetoptError:
usage(1)
gopts.remove_headers.append(value)
elif option == '-R':
gopts.remove_header_params.append(value.split(':', 1))
+ elif option == '--remove-params':
+ gopts.remove_all_params.append(value)
elif option == '-t':
gopts.totext_mask.append(value)
elif option == '-b':
--- /dev/null
+From test Sat Feb 1 00:00:00 2014
+Content-Transfer-Encoding: 7bit
+X-Foobar-Spoink-Defrobnit: wasnipoop
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+X-MIME-Autoconverted: from us-ascii to utf-8 by test id mimedecode.py
+