Skip to content

Commit

Permalink
email: support MIME Content-ID header
Browse files Browse the repository at this point in the history
- Reads from and writes into the Body parameter list.
  • Loading branch information
dcpurton authored and flatcap committed Jan 27, 2022
1 parent 17db2c8 commit 7ef0602
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions email/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,23 @@ struct Body *mutt_read_mime_header(FILE *fp, bool digest)
mutt_str_replace(&p->description, c);
rfc2047_decode(&p->description);
}
else if (mutt_istr_equal("id", line + plen))
{
// strip <angle braces> from Content-ID: header
char *id = c;
int cid_len = mutt_str_len(c);
if (cid_len > 2)
{
if (id[0] == '<')
{
id++;
cid_len--;
}
if (id[cid_len - 1] == '>')
id[cid_len - 1] = '\0';
}
mutt_param_set(&p->parameter, "content-id", id);
}
}
#ifdef SUN_ATTACHMENT
else if ((plen = mutt_istr_startswith(line, "x-sun-")))
Expand Down
15 changes: 15 additions & 0 deletions send/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ int mutt_write_mime_header(struct Body *a, FILE *fp, struct ConfigSubset *sub)
int tmplen;
char buf[256] = { 0 };

char *id = NULL;

fprintf(fp, "Content-Type: %s/%s", TYPE(a), a->subtype);

if (!TAILQ_EMPTY(&a->parameter))
Expand All @@ -784,6 +786,13 @@ int mutt_write_mime_header(struct Body *a, FILE *fp, struct ConfigSubset *sub)
struct Parameter *cont = NULL;
TAILQ_FOREACH(cont, &pl_conts, entries)
{
if (mutt_istr_equal(cont->attribute, "content-id"))
{
// Content-ID: gets its own header
id = mutt_str_dup(cont->value);
break;
}

fputc(';', fp);

buf[0] = 0;
Expand Down Expand Up @@ -816,6 +825,12 @@ int mutt_write_mime_header(struct Body *a, FILE *fp, struct ConfigSubset *sub)

fputc('\n', fp);

if (id)
{
fprintf(fp, "Content-ID: <%s>\n", id);
mutt_mem_free(&id);
}

if (a->language)
fprintf(fp, "Content-Language: %s\n", a->language);

Expand Down

0 comments on commit 7ef0602

Please sign in to comment.