Browse Source

Use basename for attachment filename.

When a file to attach is specified by a pathname, only use the
basename (without any path components) as the attachment filename.
tags/fmail-0.2.0^2
parent
commit
378dcf4b20
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      src/fmail.c

+ 9
- 2
src/fmail.c View File

@@ -419,10 +419,17 @@ initialize_magic(void)
return ctx;
}

static const char *
get_basename(const char *filename)
{
char *last_slash = strrchr(filename, '/');
return last_slash ? last_slash + 1 : filename;
}

static void
process_attachment(const char *filename, magic_t ctx, FILE *out)
{
const char *mime;
const char *mime, basename;
int binary;
FILE *f;

@@ -439,7 +446,7 @@ process_attachment(const char *filename, magic_t ctx, FILE *out)

fprintf(out, "Content-Type: %s\r\n", mime);
fprintf(out, "Content-Transfer-Encoding: %s\r\n", binary ? "base64" : "quoted-printable");
fprintf(out, "Content-Disposition: attachment; filename=%s\r\n\r\n", filename);
fprintf(out, "Content-Disposition: attachment; filename=%s\r\n\r\n", get_basename(filename));

f = fopen(filename, "r");
if ( binary )


Loading…
Cancel
Save