From: David Levine Date: Sat, 15 Sep 2012 01:46:02 +0000 (-0500) Subject: Filter out all Nmh-* headers in post(1). Do that silently for empty X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=fc15b3f63b8e802f8d6dbc36fd35c0e400313a91;p=mmh Filter out all Nmh-* headers in post(1). Do that silently for empty ones (no header body), and warn about non-empty ones. --- diff --git a/test/post/test-post-basic b/test/post/test-post-basic index a2e4fac..74ef5e1 100755 --- a/test/post/test-post-basic +++ b/test/post/test-post-basic @@ -56,9 +56,50 @@ This is a blank test EOF run_test "send -draft -server 127.0.0.1 -port $localport" \ - "post: message has no From: header + "post: message has no From: header post: See default components files for examples post: re-format message and try again send: message not delivered to anyone" +# +# Make sure that empty Nmh-* header lines are ignored, and that post +# warns about non-empty ones. +# +cat > "${MH_TEST_DIR}/Mail/draft" < +To: Somebody Else +Nmh-Attachment: +Nmh-Unused: suppress this line +Subject: Test + +This is a test +. +EOF + +cat > "${testname}.expected" < +RCPT TO: +DATA +From: Mr Nobody +To: Somebody Else +Subject: Test +Date: + +This is a test +.. +. +QUIT +EOF + +cat > "${testname}.expected_send_output" <${testname}.send_output 2>&1 + +check "${testname}.send_output" "${testname}.expected_send_output" + + exit ${failed:-0} diff --git a/test/post/test-post-common.sh b/test/post/test-post-common.sh index bd37c7d..1118d9c 100755 --- a/test/post/test-post-common.sh +++ b/test/post/test-post-common.sh @@ -33,7 +33,7 @@ test_post () # retry a few times if it fails... status=1 for i in 0 1 2 3 4 5 6 7 8 9; do - if send -draft -server 127.0.0.1 -port $localport $3 >/dev/null 2>&1 + if send -draft -server 127.0.0.1 -port $localport $3 then status=0 break diff --git a/uip/post.c b/uip/post.c index 526b5e4..ff75197 100644 --- a/uip/post.c +++ b/uip/post.c @@ -709,7 +709,21 @@ putfmt (char *name, char *str, FILE *out) } if ((i = get_header (name, hdrtab)) == NOTOK) { - fprintf (out, "%s: %s", name, str); + if (strncasecmp (name, "nmh-", 4)) { + fprintf (out, "%s: %s", name, str); + } else { + /* Filter out all Nmh-* headers, because Norm asked. They + should never have reached this point. Warn about any + that are non-empty. */ + if (strcmp (str, "\n")) { + char *newline = strchr (str, '\n'); + if (newline) *newline = '\0'; + if (! whomsw) { + advise (NULL, "ignoring header line -- %s: %s", name, str); + } + } + } + return; }