diff options
-rw-r--r-- | init.h | 1 | ||||
-rw-r--r-- | lib.c | 4 | ||||
-rw-r--r-- | mutt.h | 1 | ||||
-rw-r--r-- | rfc1524.c | 28 |
4 files changed, 27 insertions, 7 deletions
@@ -140,6 +140,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 "!^\\.[^.]" }, @@ -1243,11 +1243,11 @@ size_t mutt_quote_filename(char *d, size_t l, const char *f) for(i = 0; j < l && f[i]; i++) { - if(f[i] == '\'') + if(f[i] == '\'' || f[i] == '`') { d[j++] = '\''; d[j++] = '\\'; - d[j++] = '\''; + d[j++] = f[i]; d[j++] = '\''; } else @@ -309,6 +309,7 @@ enum OPTIMAPPASSIVE, #endif 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,13 +78,21 @@ int rfc1524_expand_command (BODY *a, char *filename, char *type, if (command[x] == '{') { char param[STRING]; + char pvalue[STRING]; + char *_pvalue; int z = 0; x++; while (command[x] && command[x] != '}' && z<sizeof(param)) param[z++] = command[x++]; param[z] = '\0'; - y += mutt_quote_filename (buf + y, sizeof (buf) - y, mutt_get_parameter(param,a->parameter)); + + _pvalue = mutt_get_parameter (param, a->parameter); + strfcpy (pvalue, NONULL(_pvalue), sizeof (pvalue)); + if (option (OPTMAILCAPSANITIZE)) + mutt_sanitize_filename (pvalue); + + y += mutt_quote_filename (buf + y, sizeof (buf) - y, pvalue); } else if (command[x] == 's' && filename != NULL) { @@ -82,8 +101,7 @@ int rfc1524_expand_command (BODY *a, char *filename, char *type, } else if (command[x] == 't') { - while (*type && y < sizeof (buf)) - buf[y++] = *type++; + y += mutt_quote_filename (buf + y, sizeof (buf) - y, type); } x++; } |