<arg choice="opt">
<option>-r header</option>
</arg>
+ <arg choice="opt">
+ <option>-R header:param</option>
+ </arg>
<arg choice="opt">
<option>-beit mask</option>
</arg>
<term>-p header:param</term>
<listitem>
<para>
- Add the pair (header, param) to a list of headers' parameters to
+ Add the pair (header, param) to a list of headers parameters to
decode; initially the list contains header "Content-Type",
parameter "name" and header "Content-Disposition", parameter
"filename".
<term>-P</term>
<listitem>
<para>
- Clear the list of headers' parameters to decode (make it empty).
+ Clear the list of headers parameters to decode (make it empty).
</para>
</listitem>
</varlistentry>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-R header:param</term>
+ <listitem>
+ <para>
+ Add the pair (header, param) to a list of headers parameters to
+ remove; initially the list is empty.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-b mask</term>
<listitem>
for header in gopts.remove_headers:
del msg[header]
+ for header, param in gopts.remove_header_params:
+ msg.del_param(param, header)
+
def set_header(msg, header, value):
"Replace header"
decode_headers = ["From", "To", "Cc", "Reply-To", "Mail-Followup-To",
"Subject"]
- # A list of headers' parameters to decode
+ # A list of headers parameters to decode
decode_header_params = [
("Content-Type", "name"),
("Content-Disposition", "filename"),
# A list of headers to remove
remove_headers = []
+ # A list of headers parameters to remove
+ remove_header_params = []
totext_mask = [] # A list of content-types to decode
binary_mask = [] # A list to pass through
from getopt import getopt, GetoptError
try:
- options, arguments = getopt(sys.argv[1:], 'hVcCDPH:f:d:p:r:b:e:i:t:o:',
+ options, arguments = getopt(sys.argv[1:],
+ 'hVcCDPH:f:d:p:r:R:b:e:i:t:o:',
['help', 'version', 'host'])
except GetoptError:
usage(1)
gopts.decode_header_params = []
elif option == '-r':
gopts.remove_headers.append(value)
+ elif option == '-R':
+ gopts.remove_header_params.append(value.split(':', 1))
elif option == '-t':
gopts.totext_mask.append(value)
elif option == '-b':
--- /dev/null
+From test Sat Feb 1 00:00:00 2014
+Return-Path: <bbb@zzz.org>
+Delivered-To: bbb@zzz.org
+Received: by mail.zzz.org (Postfix, from userid 889)
+ id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
+Content-Transfer-Encoding: 7bit
+Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
+From: bbb@ddd.com (John X. Doe)
+To: bbb@zzz.org
+Subject: This is a test message
+Date: Fri, 4 May 2001 14:05:44 -0400
+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
+
+
+Hi,
+
+Do you like this message?
+
+-Me
test_file msg_15.txt msg_15-1.txt -b text/html
test_file msg_15.txt msg_15-2.txt -i text/html
test_file msg_22.txt msg_22-1.txt -r content-id
+test_file msg_29.txt msg_29-1.txt -R Content-Type:title
if [ "$RC" -eq 0 ]; then
echo "All tests passed!"