From: Oleg Broytman Date: Sat, 8 Mar 2014 12:24:29 +0000 (+0400) Subject: Change option -d to accept a list of headers X-Git-Tag: v2.4.0~12 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=5609ebe933595e091f216abf575c448b514d7cb1;p=mimedecode.git Change option -d to accept a list of headers Change option -d to accept a comma-separated list of headers: -d h1,h2,h3,... --- diff --git a/ANNOUNCE b/ANNOUNCE index f925caf..dfca45c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -25,7 +25,8 @@ command-line options. WHAT'S NEW in version 2.4.0 (2014-03-??) - Change option -d to accept a list of headers: -d h1,h2,h3,... + Change option -d to accept a comma-separated list of headers: +-d h1,h2,h3,... Add ChangeLog. diff --git a/TODO b/TODO index f4d1e7e..fae378b 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,3 @@ -Publish docs in html format. - - -Release 2.3.9. - - -Change option -d to accept a list of headers: -d h1,h2,h3,... - - Change option -d to decode all headers and accept a list of exceptions: -d *,-h1,-h2,... @@ -19,6 +10,9 @@ Allow * and exceptions: -p *,-h1,-h2,-h3:*,-p1,-p2,-p3 +Publish docs in html format. + + Release 2.4.0. diff --git a/mimedecode.docbook b/mimedecode.docbook index 382fba2..28af4ac 100644 --- a/mimedecode.docbook +++ b/mimedecode.docbook @@ -48,7 +48,7 @@ - + @@ -199,12 +199,12 @@ - -d header + -d header1[,header2,header3...] - Add the header to a list of headers to decode; initially the list - contains headers "From", "To", "Cc", "Reply-To", "Mail-Followup-To" - and "Subject". + Add the header(s) to a list of headers to decode; initially the + list contains headers "From", "To", "Cc", "Reply-To", + "Mail-Followup-To" and "Subject". diff --git a/mimedecode.py b/mimedecode.py index 8ea6922..82f2d26 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -18,7 +18,7 @@ Broytman mimedecode.py version %s, %s 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] [--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[,header2,header3...]] [-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') @@ -113,8 +113,9 @@ def decode_headers(msg): for header, param in gopts.remove_header_params: msg.del_param(param, header) - for header in gopts.decode_headers: - decode_header(msg, header) + for header_list in gopts.decode_headers: + for header in header_list.split(','): + decode_header(msg, header) for header, param in gopts.decode_header_params: decode_header_param(msg, header, param) diff --git a/test/expected/msg_03-1.txt b/test/expected/msg_03-1.txt new file mode 100644 index 0000000..8f6c33d --- /dev/null +++ b/test/expected/msg_03-1.txt @@ -0,0 +1,18 @@ +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) +Message-ID: <15090.61304.110929.45684@aaa.zzz.org> +From: John X. Dôe +To: Jãne Y. Doe +Cc: =?utf-8?B?xIZjxI0=?= +Subject: This is a tést message +Date: Fri, 4 May 2001 14:05:44 -0400 + + +Hi, + +Do you like this message? + +-Me diff --git a/test/test_all b/test/test_all index 669d6b3..bf826c6 100755 --- a/test/test_all +++ b/test/test_all @@ -39,6 +39,7 @@ for f in input/*.txt; do test_file "$n" "$n" done +test_file msg_03.txt msg_03-1.txt -D -d From,To,Subject 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