summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-02-10 21:42:28 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-02-10 21:42:28 +0000
commit8efe5139b94a49ef07dfdd855b5ad2395192ef44 (patch)
treeaed8279116c9fb0d35c2ec143742be89d9977b09
parente390dfe2ebac27840981c688b1828f4075a98005 (diff)
[stable] $mailcap_sanitize
-rw-r--r--init.h1
-rw-r--r--lib.c6
-rw-r--r--mutt.h1
-rw-r--r--rfc1524.c31
4 files changed, 31 insertions, 8 deletions
diff --git a/init.h b/init.h
index 9edc74cd..08907f06 100644
--- a/init.h
+++ b/init.h
@@ -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 "!^\\.[^.]" },
diff --git a/lib.c b/lib.c
index 9cfbc408..650594e8 100644
--- a/lib.c
+++ b/lib.c
@@ -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
diff --git a/mutt.h b/mutt.h
index 5f422c4d..586b1b68 100644
--- a/mutt.h
+++ b/mutt.h
@@ -303,6 +303,7 @@ enum
OPTHIDDENHOST,
OPTIGNORELISTREPLYTO,
OPTIMPLICITAUTOVIEW,
+ OPTMAILCAPSANITIZE,
OPTMARKERS,
OPTMARKOLD,
OPTMENUSCROLL, /* scroll menu instead of implicit next-page */
diff --git a/rfc1524.c b/rfc1524.c
index 7bbc748a..6a349234 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,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++;
}