diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-02-10 21:42:28 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-02-10 21:42:28 +0000 |
commit | 8efe5139b94a49ef07dfdd855b5ad2395192ef44 (patch) | |
tree | aed8279116c9fb0d35c2ec143742be89d9977b09 | |
parent | e390dfe2ebac27840981c688b1828f4075a98005 (diff) |
[stable] $mailcap_sanitize
-rw-r--r-- | init.h | 1 | ||||
-rw-r--r-- | lib.c | 6 | ||||
-rw-r--r-- | mutt.h | 1 | ||||
-rw-r--r-- | rfc1524.c | 31 |
4 files changed, 31 insertions, 8 deletions
@@ -138,6 +138,7 @@ struct option_t MuttVars[] = { { "locale", DT_STR, R_BOTH, UL &Locale, UL "C" }, { "mail_check", DT_NUM, R_NONE, UL &BuffyTimeout, 5 }, { "mailcap_path", DT_STR, R_NONE, UL &MailcapPath, 0 }, + { "mailcap_sanitize", DT_BOOL, R_NONE, OPTMAILCAPSANITIZE, 1 }, { "mark_old", DT_BOOL, R_BOTH, OPTMARKOLD, 1 }, { "markers", DT_BOOL, R_PAGER, OPTMARKERS, 1 }, { "mask", DT_RX, R_NONE, UL &Mask, UL "!^\\.[^.]" }, @@ -1231,7 +1231,7 @@ char *mutt_quote_filename(const char *f) for(i = 0, l = 3; f[i]; i++, l++) { - if(f[i] == '\'') + if(f[i] == '\'' || f[i] == '`') l += 3; } @@ -1242,11 +1242,11 @@ char *mutt_quote_filename(const char *f) for(i = 0; f[i]; i++) { - if(f[i] == '\'') + if(f[i] == '\'' || f[i] == '`') { d[l++] = '\''; d[l++] = '\\'; - d[l++] = '\''; + d[l++] = f[i]; d[l++] = '\''; } else @@ -303,6 +303,7 @@ enum OPTHIDDENHOST, OPTIGNORELISTREPLYTO, OPTIMPLICITAUTOVIEW, + OPTMAILCAPSANITIZE, OPTMARKERS, OPTMARKOLD, OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ @@ -48,13 +48,24 @@ * In addition, this function returns a 0 if the command works on a file, * and 1 if the command works on a pipe. */ -int rfc1524_expand_command (BODY *a, char *filename, char *type, +int rfc1524_expand_command (BODY *a, char *_filename, char *_type, char *command, int clen) { int x=0,y=0; int needspipe = TRUE; char buf[LONG_STRING]; - + char filename[_POSIX_PATH_MAX]; + char type[LONG_STRING]; + + strfcpy (filename, _filename, sizeof (filename)); + strfcpy (type, _type, sizeof (type)); + + if (option (OPTMAILCAPSANITIZE)) + { + mutt_sanitize_filename (filename); + mutt_sanitize_filename (type); + } + while (command[x] && x<clen && y<sizeof(buf)) { if (command[x] == '\\') { @@ -67,15 +78,21 @@ int rfc1524_expand_command (BODY *a, char *filename, char *type, if (command[x] == '{') { char param[STRING]; + char pvalue[LONG_STRING]; int z = 0; char *ret = NULL; + char *pv; x++; while (command[x] && command[x] != '}' && z<sizeof(param)) param[z++] = command[x++]; param[z] = '\0'; dprint(2,(debugfile,"Parameter: %s Returns: %s\n",param,ret)); - ret = mutt_quote_filename(mutt_get_parameter(param,a->parameter)); + pv = mutt_get_parameter (param, a->parameter); + strfcpy (pvalue, NONULL(pv), sizeof (pvalue)); + if (option (OPTMAILCAPSANITIZE)) + mutt_sanitize_filename (pvalue); + ret = mutt_quote_filename (pvalue); dprint(2,(debugfile,"Parameter: %s Returns: %s\n",param,ret)); z = 0; while (ret && ret[z] && y<sizeof(buf)) @@ -95,8 +112,12 @@ int rfc1524_expand_command (BODY *a, char *filename, char *type, } else if (command[x] == 't') { - while (*type && y < sizeof (buf)) - buf[y++] = *type++; + char *t = mutt_quote_filename (type); + char *s; + + for (s = t; *s && y < sizeof (buf);) + buf[y++] = *s++; + FREE (&t); } x++; } |