summaryrefslogtreecommitdiffstats
path: root/rfc1524.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-02-10 21:42:05 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-02-10 21:42:05 +0000
commit40aab0a8b99e842d3f9f0928f3fdb7305a944893 (patch)
treefdac5b82780363d71e437fbc5cca0db61db8caf6 /rfc1524.c
parent15739ddd2345d227a16d18a3abfb740ae7c2ec0f (diff)
[unstable] $mailcap_sanitize.
Diffstat (limited to 'rfc1524.c')
-rw-r--r--rfc1524.c28
1 files changed, 23 insertions, 5 deletions
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++;
}