summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--init.h1
-rw-r--r--lib.c4
-rw-r--r--mutt.h1
-rw-r--r--rfc1524.c28
4 files changed, 27 insertions, 7 deletions
diff --git a/init.h b/init.h
index 5875e8ef..8a7dde29 100644
--- a/init.h
+++ b/init.h
@@ -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 "!^\\.[^.]" },
diff --git a/lib.c b/lib.c
index 9da75085..7ef202bd 100644
--- a/lib.c
+++ b/lib.c
@@ -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
diff --git a/mutt.h b/mutt.h
index 190375b5..c1f0ddf4 100644
--- a/mutt.h
+++ b/mutt.h
@@ -309,6 +309,7 @@ enum
OPTIMAPPASSIVE,
#endif
OPTIMPLICITAUTOVIEW,
+ OPTMAILCAPSANITIZE,
OPTMARKERS,
OPTMARKOLD,
OPTMENUSCROLL, /* scroll menu instead of implicit next-page */
diff --git a/rfc1524.c b/rfc1524.c
index 28c6e757..9d6ac2da 100644
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -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++;
}