<arg choice="opt">
<option>-d header1[,header2,header3...]</option>
</arg>
+ <arg choice="opt">
+ <option>-d *[,-header1,-header2,-header3...]</option>
+ </arg>
<arg choice="opt">
<option>-p header:param</option>
</arg>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-d *[,-header1,-header2,-header3...]</term>
+ <listitem>
+ <para>
+ This variant completely changes headers decoding. First, the list of
+ headers to decode is cleared. Then all the headers are decoded
+ except the given list of exceptions (headers listed with '-'). In
+ this mode it would be meaningless to give more than one -d options
+ but the program doesn't enforce it.
+ </para>
+
+ <para>
+ Please be warned that the asterisk is a shell metacharacter and
+ should be escaped or quoted. Either write -d \*,-h1,-h2 or -d
+ '*,-h1,-h2'.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-D</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 header1[,header2,header3...]] [-p header:param] [-r header] [-R header:param] [--remove-params=header] [-beit mask] [-o output_file] [input_file [output_file]]
+Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-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')
msg.del_param(param, header)
for header_list in gopts.decode_headers:
- for header in header_list.split(','):
- decode_header(msg, header)
+ header_list = header_list.split(',')
+ if header_list[0] == '*': # Decode all headers except listed
+ header_list = [h[1:].lower() for h in header_list[1:] if h[0]=='-']
+ for header in msg.keys():
+ if header.lower() not in header_list:
+ decode_header(msg, header)
+ else: # Decode listed hiders
+ for header in header_list:
+ decode_header(msg, header)
for header, param in gopts.decode_header_params:
decode_header_param(msg, header, param)
elif option == '-f':
gopts.default_encoding = value
elif option == '-d':
+ if value.startswith('*'):
+ gopts.decode_headers = []
gopts.decode_headers.append(value)
elif option == '-D':
gopts.decode_headers = []
done
test_file msg_03.txt msg_03-1.txt -D -d From,To,Subject
+test_file msg_03.txt msg_03-1.txt -d '*,-cc'
+test_file msg_03.txt msg_03-1.txt -d \*,From,To,Subject,-cc
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