From 41fea01066539ed8e958c21591a5fe7155565ceb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Nov 2011 22:25:35 +0100 Subject: sendmail: stop doing -t unconditionally; makemime: generate 76 char base64 lines Signed-off-by: Denys Vlasenko --- mailutils/mail.c | 2 +- mailutils/sendmail.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'mailutils') diff --git a/mailutils/mail.c b/mailutils/mail.c index f5260d9db..199f64407 100644 --- a/mailutils/mail.c +++ b/mailutils/mail.c @@ -119,7 +119,7 @@ static char* FAST_FUNC parse_url(char *url, char **user, char **pass) void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol) { enum { - SRC_BUF_SIZE = 45, /* This *MUST* be a multiple of 3 */ + SRC_BUF_SIZE = 57, /* This *MUST* be a multiple of 3 */ DST_BUF_SIZE = 4 * ((SRC_BUF_SIZE + 2) / 3), }; #define src_buf text diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index dbd491002..f96ca3291 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -281,17 +281,19 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) // analyze headers // To: or Cc: headers add recipients - if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { - rcptto(sane_address(s+3)); - goto addheader; + if (opts & OPT_t) { + if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) { + rcptto(sane_address(s+3)); + goto addheader; + } + // Bcc: header adds blind copy (hidden) recipient + if (0 == strncasecmp("Bcc:", s, 4)) { + rcptto(sane_address(s+4)); + free(s); + continue; // N.B. Bcc: vanishes from headers! + } } - // Bcc: header adds blind copy (hidden) recipient - if (0 == strncasecmp("Bcc:", s, 4)) { - rcptto(sane_address(s+4)); - free(s); - // N.B. Bcc: vanishes from headers! - } else - if (strchr(s, ':') || (list && skip_whitespace(s) != s)) { + if (strchr(s, ':') || (list && isspace(s))) { // other headers go verbatim // N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines. // Continuation is denoted by prefixing additional lines with whitespace(s). -- cgit v1.2.3 From 578b8171511f67a9c2afc5c6ae9745de9f9b5e42 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 19 Nov 2011 13:54:50 +0100 Subject: sendmail: fix a mistake in previous commit Signed-off-by: Denys Vlasenko --- mailutils/sendmail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mailutils') diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index f96ca3291..aa381c60f 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c @@ -293,7 +293,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv) continue; // N.B. Bcc: vanishes from headers! } } - if (strchr(s, ':') || (list && isspace(s))) { + if (strchr(s, ':') || (list && isspace(s[0]))) { // other headers go verbatim // N.B. RFC2822 2.2.3 "Long Header Fields" allows for headers to occupy several lines. // Continuation is denoted by prefixing additional lines with whitespace(s). -- cgit v1.2.3 From 3bc4fc5857e2daba601442f95771a590bce915bc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 19 Nov 2011 13:55:46 +0100 Subject: makemime: content-type should default to application/octet-stream Signed-off-by: Denys Vlasenko --- mailutils/mail.h | 7 ------- mailutils/makemime.c | 5 +++-- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'mailutils') diff --git a/mailutils/mail.h b/mailutils/mail.h index d1d783055..fa0c5b378 100644 --- a/mailutils/mail.h +++ b/mailutils/mail.h @@ -16,22 +16,15 @@ struct globals { char *pass; FILE *fp0; // initial stdin char *opt_charset; - char *content_type; }; #define G (*ptr_to_globals) #define timeout (G.timeout ) #define verbose (G.verbose ) #define opts (G.opts ) -//#define user (G.user ) -//#define pass (G.pass ) -//#define fp0 (G.fp0 ) -//#define opt_charset (G.opt_charset) -//#define content_type (G.content_type) #define INIT_G() do { \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ G.opt_charset = (char *)CONFIG_FEATURE_MIME_CHARSET; \ - G.content_type = (char *)"text/plain"; \ } while (0) //char FAST_FUNC *parse_url(char *url, char **user, char **pass); diff --git a/mailutils/makemime.c b/mailutils/makemime.c index a9ff03d03..f1ef602a4 100644 --- a/mailutils/makemime.c +++ b/mailutils/makemime.c @@ -146,6 +146,7 @@ int makemime_main(int argc UNUSED_PARAM, char **argv) { llist_t *opt_headers = NULL, *l; const char *opt_output; + const char *content_type = "application/octet-stream"; #define boundary opt_output enum { @@ -165,7 +166,7 @@ int makemime_main(int argc UNUSED_PARAM, char **argv) opt_complementary = "a::"; opts = getopt32(argv, "c:e:o:C:N:a:", //:m:j:", - &G.content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL + &content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL ); //argc -= optind; argv += optind; @@ -202,7 +203,7 @@ int makemime_main(int argc UNUSED_PARAM, char **argv) "Content-Disposition: inline; filename=\"%s\"\n" "Content-Transfer-Encoding: base64\n" , boundary - , G.content_type + , content_type , G.opt_charset , bb_get_last_path_component_strip(*argv) ); -- cgit v1.2.3 From fc186711fe75cfc4abda9a7ff29050bc7a56313b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 19 Nov 2011 14:43:02 +0100 Subject: makemime: document our current behavior. Tweak help text Signed-off-by: Denys Vlasenko --- mailutils/makemime.c | 29 +++++++++++++++++++++++++---- mailutils/reformime.c | 1 - 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'mailutils') diff --git a/mailutils/makemime.c b/mailutils/makemime.c index f1ef602a4..4b07e54de 100644 --- a/mailutils/makemime.c +++ b/mailutils/makemime.c @@ -1,7 +1,6 @@ /* vi: set sw=4 ts=4: */ /* * makemime: create MIME-encoded message - * reformime: parse MIME-encoded message * * Copyright (C) 2008 by Vladimir Dronnikov * @@ -135,12 +134,35 @@ Content-Transfer-Encoding: 7bit //usage: "\n -o FILE Output. Default: stdout" //usage: "\n -a HDR Add header. Examples:" //usage: "\n \"From: user@host.org\", \"Date: `date -R`\"" -//usage: "\n -c CT Content type. Default: text/plain" +//usage: "\n -c CT Content type. Default: application/octet-stream" //usage: "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET /* //usage: "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */ //usage: "\n" //usage: "\nOther options are silently ignored" +/* + * -c [Content-Type] should create just one MIME section + * with "Content-Type:", "Content-Transfer-Encoding:", and HDR from "-a HDR". + * NB: without "Content-Disposition:" auto-added, unlike we do now + * NB2: -c has *optional* param which nevertheless _can_ be specified after a space :( + * + * -m [multipart/mixed] should create multipart MIME section + * with "Content-Type:", "Content-Transfer-Encoding:", and HDR from "-a HDR", + * and add FILE to it _verbatim_: + * HEADERS + * + * --=_1_1321709112_1605 + * FILE_CONTENTS + * --=_1_1321709112_1605 + * without any encoding of FILE_CONTENTS. (Basically, it expects that FILE + * is the result of "makemime -c"). + * + * -j MULTIPART_FILE1 SINGLE_FILE2 should output MULTIPART_FILE1 + SINGLE_FILE2 + * + * Our current behavior is a mutant "-m + -c + -j" one: we create multipart MIME + * and we put "-c" encoded FILEs into many multipart sections. + */ + int makemime_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int makemime_main(int argc UNUSED_PARAM, char **argv) { @@ -148,7 +170,6 @@ int makemime_main(int argc UNUSED_PARAM, char **argv) const char *opt_output; const char *content_type = "application/octet-stream"; #define boundary opt_output - enum { OPT_c = 1 << 0, // create (non-multipart) section OPT_e = 1 << 1, // Content-Transfer-Encoding. Ignored. Assumed base64 @@ -165,7 +186,7 @@ int makemime_main(int argc UNUSED_PARAM, char **argv) // parse options opt_complementary = "a::"; opts = getopt32(argv, - "c:e:o:C:N:a:", //:m:j:", + "c:e:o:C:N:a:", // "m:j:", &content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL ); //argc -= optind; diff --git a/mailutils/reformime.c b/mailutils/reformime.c index 5e28ef729..8e7d455f6 100644 --- a/mailutils/reformime.c +++ b/mailutils/reformime.c @@ -1,6 +1,5 @@ /* vi: set sw=4 ts=4: */ /* - * makemime: create MIME-encoded message * reformime: parse MIME-encoded message * * Copyright (C) 2008 by Vladimir Dronnikov -- cgit v1.2.3