]> granicus.if.org Git - neomutt/commitdiff
mutt_file_sanitize_filename bool param
authorRichard Russon <rich@flatcap.org>
Sun, 27 May 2018 18:33:25 +0000 (19:33 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 28 May 2018 13:19:39 +0000 (14:19 +0100)
attach.c
handler.c
mutt/file.c
mutt/file.h
muttlib.c
rfc1524.c

index 186e1e01df0c0061fc4d66fb5e240b00e64ee1d2..96d3b6573d742266eaee16b1015b9151c8ce1360 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -419,7 +419,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr,
     if (fp)
     {
       fname = mutt_str_strdup(a->filename);
-      mutt_file_sanitize_filename(fname, 1);
+      mutt_file_sanitize_filename(fname, true);
     }
     else
       fname = a->filename;
index 8b93c8c45ae1fe58911821def3530861e6630673..66dee8d1e31d021e4e9571abbfdfcb3fd3c0acc9 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1453,7 +1453,7 @@ static int autoview_handler(struct Body *a, struct State *s)
   rfc1524_mailcap_lookup(a, type, entry, MUTT_AUTOVIEW);
 
   fname = mutt_str_strdup(a->filename);
-  mutt_file_sanitize_filename(fname, 1);
+  mutt_file_sanitize_filename(fname, true);
   rfc1524_expand_filename(entry->nametemplate, fname, tempfile, sizeof(tempfile));
   FREE(&fname);
 
index 1cf3f91e76c30fe7f4dd8cc9f85a1c19ab66cf94..4cfe5c6a588671704dbf879e7b0d3a06a2bb20e8 100644 (file)
@@ -546,14 +546,14 @@ FILE *mutt_file_fopen(const char *path, const char *mode)
  * @param f     Filename to make safe
  * @param slash Replace '/' characters too
  */
-void mutt_file_sanitize_filename(char *f, short slash)
+void mutt_file_sanitize_filename(char *f, bool slash)
 {
   if (!f)
     return;
 
   for (; *f; f++)
   {
-    if ((slash && *f == '/') || !strchr(safe_chars, *f))
+    if ((slash && (*f == '/')) || !strchr(safe_chars, *f))
       *f = '_';
   }
 }
index ad1ed571a545083117194a0fce0b9922100bf8e7..88d3a1fee4440c076494b5d9b2d868fe9a9bf672 100644 (file)
@@ -61,7 +61,7 @@ char *      mutt_file_read_line(char *s, size_t *size, FILE *fp, int *line, int
 int         mutt_file_rename(char *oldfile, char *newfile);
 int         mutt_file_rmtree(const char *path);
 int         mutt_file_safe_rename(const char *src, const char *target);
-void        mutt_file_sanitize_filename(char *f, short slash);
+void        mutt_file_sanitize_filename(char *f, bool slash);
 int         mutt_file_sanitize_regex(char *dest, size_t destlen, const char *src);
 void        mutt_file_set_mtime(const char *from, const char *to);
 int         mutt_file_symlink(const char *oldpath, const char *newpath);
index f565fe01ca3a66dcc57319bd0b570b3594454c78..7c91f2a0a528cba4d3b8a2a442ac9dcb5897a526 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -92,7 +92,7 @@ void mutt_adv_mktemp(char *s, size_t l)
   {
     char prefix[_POSIX_PATH_MAX];
     mutt_str_strfcpy(prefix, s, sizeof(prefix));
-    mutt_file_sanitize_filename(prefix, 1);
+    mutt_file_sanitize_filename(prefix, true);
     snprintf(s, l, "%s/%s", NONULL(Tmpdir), prefix);
     struct stat sb;
     if (lstat(s, &sb) == -1 && errno == ENOENT)
index c75008e5f576defba1a15cdebe9a72cc8852c8bd..c9871e6978beb1be1b64984c0d6bf8c9794cee62 100644 (file)
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -74,7 +74,7 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *type, char *com
   mutt_str_strfcpy(type2, type, sizeof(type2));
 
   if (MailcapSanitize)
-    mutt_file_sanitize_filename(type2, 0);
+    mutt_file_sanitize_filename(type2, false);
 
   while (x < clen - 1 && command[x] && y < sizeof(buf) - 1)
   {
@@ -101,7 +101,7 @@ int rfc1524_expand_command(struct Body *a, char *filename, char *type, char *com
         pvalue2 = mutt_param_get(&a->parameter, param);
         mutt_str_strfcpy(pvalue, NONULL(pvalue2), sizeof(pvalue));
         if (MailcapSanitize)
-          mutt_file_sanitize_filename(pvalue, 0);
+          mutt_file_sanitize_filename(pvalue, false);
 
         y += mutt_file_quote_filename(buf + y, sizeof(buf) - y, pvalue);
       }