diff --git a/src/session/download.c b/src/session/download.c index bed83952b..da7181d8e 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -785,6 +785,9 @@ static unsigned char * subst_file(unsigned char *prog, unsigned char *file) { struct string name; + /* When there is no %s in the mailcap entry, the handler program reads + * data from stdin instead of a file. */ + int input = 1; if (!init_string(&name)) return NULL; @@ -797,6 +800,7 @@ subst_file(unsigned char *prog, unsigned char *file) prog += p; if (*prog == '%') { + input = 0; #if defined(HAVE_CYGWIN_CONV_TO_FULL_WIN32_PATH) #ifdef MAX_PATH unsigned char new_path[MAX_PATH]; @@ -813,6 +817,19 @@ subst_file(unsigned char *prog, unsigned char *file) } } + if (input) { + struct string s; + + if (init_string(&s)) { + add_to_string(&s, "/bin/cat "); + add_char_to_string(&s, '"'); + add_to_string(&s, file); + add_to_string(&s, "\" | "); + add_string_to_string(&s, &name); + done_string(&name); + return s.source; + } + } return name.source; }