Add option --set-header=header:value to set header's value (only at the top
level).
+ Add option --set-param=header:param=value to set header parameter's value
+(only at the top level).
+
WHAT'S NEW in version 2.4.0 (2014-03-08)
Change option -d to accept a comma-separated list of headers:
-Add option --set-param=header:param=value to set header parameter's value (only
-at the top level).
-
-
Add options --save-headers, --save-body and --save-message to save
decoded headers/bodies/messages of parts to files.
<arg choice="opt">
<option>--set-header header:value</option>
</arg>
+ <arg choice="opt">
+ <option>--set-param header:param=value</option>
+ </arg>
<arg choice="opt">
<option>-beit mask</option>
</arg>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>--set-param header:param=value</term>
+ <listitem>
+ <para>
+ The program sets or changes value for the header's parameter to the
+ given value (only at the top-level message). The header must exist.
+ </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 header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [-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 header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [--set-param header:param=value] [-beit mask] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
sys.stderr.write(errormsg + '\n')
# A list of header/value pairs to set
set_header_value = []
# A list of header/parameter/value triples to set
- #set_header_param = []
+ set_header_param = []
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=', 'set-header='])
+ ['help', 'version', 'host=', 'set-header=', 'set-param='])
except GetoptError:
usage(1)
gopts.remove_headers_params.append(value.split(':', 1))
elif option == '--set-header':
gopts.set_header_value.append(value.split(':', 1))
+ elif option == '--set-param':
+ header, value = value.split(':', 1)
+ if '=' in value:
+ param, value = value.split('=', 1)
+ else:
+ param, value = value.split(':', 1)
+ gopts.set_header_param.append((header, param, value))
elif option == '-t':
gopts.totext_mask.append(value)
elif option == '-b':
for header, value in gopts.set_header_value:
msg[header] = value
+ for header, param, value in gopts.set_header_param:
+ msg.set_param(param, value, header)
+
try:
decode_message(msg)
finally:
--- /dev/null
+From test Sat Feb 1 00:00:00 2014
+MIME-version: 1.0
+From: ppp-request@zzz.org
+Sender: ppp-admin@zzz.org
+To: ppp@zzz.org
+Subject: Ppp digest, Vol 1 #2 - 5 msgs
+Date: Fri, 20 Apr 2001 20:18:00 -0400 (EDT)
+X-Mailman-Version: 2.0.4
+Content-Type: multipart/mixed; boundary="192.168.1.2.889.32614.987812255.500.21814"
+X-Mailer: Mailman v2.0.4; test="set"
+
+
+--192.168.1.2.889.32614.987812255.500.21814
+Content-description: Masthead (Ppp digest, Vol 1 #2)
+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
+
+Send Ppp mailing list submissions to
+ ppp@zzz.org
+
+To subscribe or unsubscribe via the World Wide Web, visit
+ http://www.zzz.org/mailman/listinfo/ppp
+or, via email, send a message with subject or body 'help' to
+ ppp-request@zzz.org
+
+You can reach the person managing the list at
+ ppp-admin@zzz.org
+
+When replying, please edit your Subject line so it is more specific
+than "Re: Contents of Ppp digest..."
+
+
+--192.168.1.2.889.32614.987812255.500.21814
+Content-description: Today's Topics (5 msgs)
+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
+
+Today's Topics:
+
+ 1. testing #1 (Barry A. Warsaw)
+ 2. testing #2 (Barry A. Warsaw)
+ 3. testing #3 (Barry A. Warsaw)
+ 4. testing #4 (Barry A. Warsaw)
+ 5. testing #5 (Barry A. Warsaw)
+
+--192.168.1.2.889.32614.987812255.500.21814
+Content-Type: multipart/digest; boundary="__--__--"
+
+
+--__--__--
+
+Message: 1
+Content-Transfer-Encoding: 7bit
+Date: Fri, 20 Apr 2001 20:16:13 -0400
+To: ppp@zzz.org
+From: barry@digicool.com (Barry A. Warsaw)
+Subject: [Ppp] testing #1
+Precedence: bulk
+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
+
+
+hello
+
+
+--__--__--
+
+Message: 2
+Date: Fri, 20 Apr 2001 20:16:21 -0400
+Content-Transfer-Encoding: 7bit
+To: ppp@zzz.org
+From: barry@digicool.com (Barry A. Warsaw)
+Precedence: bulk
+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
+
+
+hello
+
+
+--__--__--
+
+Message: 3
+Date: Fri, 20 Apr 2001 20:16:25 -0400
+Content-Transfer-Encoding: 7bit
+To: ppp@zzz.org
+From: barry@digicool.com (Barry A. Warsaw)
+Subject: [Ppp] testing #3
+Precedence: bulk
+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
+
+
+hello
+
+
+--__--__--
+
+Message: 4
+Date: Fri, 20 Apr 2001 20:16:28 -0400
+Content-Transfer-Encoding: 7bit
+To: ppp@zzz.org
+From: barry@digicool.com (Barry A. Warsaw)
+Subject: [Ppp] testing #4
+Precedence: bulk
+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
+
+
+hello
+
+
+--__--__--
+
+Message: 5
+Date: Fri, 20 Apr 2001 20:16:32 -0400
+Content-Transfer-Encoding: 7bit
+To: ppp@zzz.org
+From: barry@digicool.com (Barry A. Warsaw)
+Subject: [Ppp] testing #5
+Precedence: bulk
+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
+
+
+hello
+
+
+
+
+--__--__----
+
+--192.168.1.2.889.32614.987812255.500.21814
+Content-description: Digest Footer
+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
+
+_______________________________________________
+Ppp mailing list
+Ppp@zzz.org
+http://www.zzz.org/mailman/listinfo/ppp
+
+
+--192.168.1.2.889.32614.987812255.500.21814--
+
+End of Ppp Digest
+
test_file msg_29.txt msg_29-1.txt -R Content-Type:title
test_file msg_18.txt msg_18-1.txt -R X-Foobar-Spoink-Defrobnit:\*
test_file msg_01.txt msg_01-1.txt --set-header=X-Test:set
+test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test=set
+test_file msg_02.txt msg_02-1.txt --set-param=X-Mailer:test:set
if [ "$RC" -eq 0 ]; then
echo "All tests passed!"