From 3410b680416c49a7617491af38bc1929855a331d Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 12 Apr 2012 16:12:43 +0200 Subject: [PATCH] mhstore: Made -auto the default. Now, that tar files are not extracted automatically anymore, it's quite safe to have -auto, as nothing unexpected will happen. Still, existing files will be overwritten, but that's the case with -noauto too. --- man/mhstore.man1 | 17 +++++++------- uip/mhstore.c | 67 +++++++++++++++++++----------------------------------- 2 files changed, 32 insertions(+), 52 deletions(-) diff --git a/man/mhstore.man1 b/man/mhstore.man1 index 61e2ab2..faf8ea5 100644 --- a/man/mhstore.man1 +++ b/man/mhstore.man1 @@ -135,9 +135,9 @@ nmh-storage: /tmp If this entry isn't present, the current working directory is used. .PP -If the +By default (or if the .B \-auto -switch is given, then +switch is given), then .B mhstore will check if the message contains information indicating the filename that should @@ -145,13 +145,12 @@ be used to store the content. This information should be specified as the attribute \*(lqname=filename\*(rq in the \*(lqContent-Type\*(rq header for the content you are storing. For security reasons, this filename will be ignored if it begins with the character '/', '.', '|', or '!', -or if it contains the character '%'. For the sake of security, -this switch is not the default, and it is recommended that you do -NOT put the +or if it contains the character '%'. Now that tar files are not extracted +automatically anymore, having .B \-auto -switch in your -.I \&.mmh/profile -file. +as the default is quite safe. +Attachments are only stored below the current (or the storage) +directory. In the worst case, existing files there will be overwritten. .PP If the .B \-auto @@ -385,7 +384,7 @@ mhbuild(1), mhlist(1), mhshow(1), sendfiles(1) .nf .RB ` +folder "' defaults to the current folder" .RB ` msgs "' defaults to cur" -.RB ` \-noauto ' +.RB ` \-auto ' .SH CONTEXT If a folder is given, it will become the current folder. The last diff --git a/uip/mhstore.c b/uip/mhstore.c index 992d429..6f6746d 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -71,7 +71,7 @@ void freects_done(int) NORETURN; */ static void pipeser(int); -int autosw = 0; +int autosw = 1; /* ** Cache of current directory. This must be @@ -114,7 +114,6 @@ static int store_content(CT, CT); static int output_content_file(CT, int); static int output_content_folder(char *, char *); static int parse_format_string(CT, char *, char *, int, char *); -static void get_storeproc(CT); static int copy_some_headers(FILE *, CT); static void store_all_messages(CT *); @@ -383,8 +382,6 @@ store_all_messages(CT *cts) ** Check for the directory in which to ** store any contents. */ - if (autosw) - dir = getcpy(cwd); if ((cp = context_find(nmhstorage)) && *cp) dir = getcpy(cp); else @@ -473,13 +470,32 @@ store_switch(CT ct) static int store_generic(CT ct) { + char **ap, **ep, *cp; + CI ci = &ct->c_ctinfo; + /* - ** Check if the content specifies a filename. + ** Check if the content specifies a filename in its MIME parameters. ** Don't bother with this for type "message" - ** (only "message/rfc822" will use store_generic). + ** (only the "message" subtype "rfc822" will use store_generic). + ** The storeproc may already be defined, if this content + ** is part of a "message/external", for instance. */ - if (autosw && ct->c_type != CT_MESSAGE) - get_storeproc(ct); + if (autosw && ct->c_type != CT_MESSAGE && !ct->c_storeproc) { + /* + ** Check the attribute/value pairs, for the attribute "name". + ** If found, do a few sanity checks and copy the value into + ** the storeproc. + */ + for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { + if (mh_strcasecmp(*ap, "name")==0 && + *(cp = *ep) != '/' && *cp != '.' && + *cp != '|' && *cp != '!' && + !strchr(cp, '%')) { + ct->c_storeproc = getcpy(cp); + break; + } + } + } return store_content(ct, NULL); } @@ -1230,41 +1246,6 @@ raw: /* -** Check if the content specifies a filename -** in its MIME parameters. -*/ - -static void -get_storeproc(CT ct) -{ - char **ap, **ep, *cp; - CI ci = &ct->c_ctinfo; - - /* - ** If the storeproc has already been defined, - ** we just return (for instance, if this content - ** is part of a "message/external". - */ - if (ct->c_storeproc) - return; - - /* - ** Check the attribute/value pairs, for the attribute "name". - ** If found, do a few sanity checks and copy the value into - ** the storeproc. - */ - for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) { - if (!mh_strcasecmp(*ap, "name") && *(cp = *ep) != '/' && - *cp != '.' && *cp != '|' && *cp != '!' && - !strchr(cp, '%')) { - ct->c_storeproc = getcpy(cp); - return; - } - } -} - - -/* ** Copy some of the header fields of the initial message/partial ** message into the header of the reassembled message. */ -- 1.7.10.4