From: Oleg Broytman Date: Mon, 10 Mar 2014 15:24:07 +0000 (+0400) Subject: The header for --set-param must exist X-Git-Tag: v2.5.0~33 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=6d07224f7d97f388336a38b325c3ab25f85f2e2e;p=mimedecode.git The header for --set-param must exist --- diff --git a/ANNOUNCE b/ANNOUNCE index e3be73c..cf2f308 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -29,7 +29,7 @@ WHAT'S NEW in version 2.5.0 (2014-03-??) level). Add option --set-param=header:param=value to set header parameter's value -(only at the top level). +(only at the top level). The header must exist. WHAT'S NEW in version 2.4.0 (2014-03-08) diff --git a/mimedecode.py b/mimedecode.py index 70776d3..50bdcd4 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -500,7 +500,8 @@ if __name__ == "__main__": msg[header] = value for header, param, value in gopts.set_header_param: - msg.set_param(param, value, header) + if header in msg: + msg.set_param(param, value, header) try: decode_message(msg) diff --git a/test/expected/msg_01-2.txt b/test/expected/msg_01-2.txt new file mode 100644 index 0000000..09c4e43 --- /dev/null +++ b/test/expected/msg_01-2.txt @@ -0,0 +1,22 @@ +From test Sat Feb 1 00:00:00 2014 +Return-Path: +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 +X-Test: set; test="set" +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 diff --git a/test/test_all b/test/test_all index c627685..4401053 100755 --- a/test/test_all +++ b/test/test_all @@ -54,6 +54,8 @@ test_file msg_16.txt msg_16-2.txt -r \*,-mime-version,-content-type 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_01.txt msg_01-2.txt --set-header=X-Test:set --set-param=X-Test:test:set +test_file msg_02.txt msg_02.txt --set-param=X-Test: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