From f3662faba6eee9f5136ebbd2b326d10c648ca7ac Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 1 Mar 2021 22:12:18 -0500 Subject: Generate properly populated reply Cc lists --- html.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index fe96a37..77438a0 100644 --- a/html.c +++ b/html.c @@ -107,17 +107,35 @@ static char *htmlMbox(const char *messageID) { return templateString("../" PATH_MESSAGE, vars, escapeURL); } +static int htmlReplyCc(FILE *file, bool first, struct AddressList list) { + for (size_t i = 0; i < list.len; ++i) { + const char *template = "[,][mailbox]@[host]"; + struct Variable vars[] = { + { "mailbox", list.addrs[i].mailbox }, + { "host", list.addrs[i].host }, + { ",", (!first || i ? "," : "") }, + {0}, + }; + int error = templateRender(file, template, vars, escapeURL); + if (error) return error; + } + return 0; +} + static char *htmlReply(const struct Envelope *envelope) { + char *buf; + size_t len; + FILE *file = open_memstream(&buf, &len); + if (!file) err(EX_OSERR, "open_memstream"); const char *template = { "mailto:[mailbox]@[host]" - "?cc=[cc]" - "&subject=[re][subject]" + "?subject=[re][subject]" "&In-Reply-To=[<][messageID][>]" + "&cc=" }; struct Variable vars[] = { { "mailbox", envelope->replyTo.mailbox }, { "host", envelope->replyTo.host }, - { "cc", baseMailto }, { "re", (strncmp(envelope->subject, "Re: ", 4) ? "Re: " : "") }, { "subject", envelope->subject }, { "messageID", envelope->messageID }, @@ -125,7 +143,13 @@ static char *htmlReply(const struct Envelope *envelope) { { ">", ">" }, {0}, }; - return templateString(template, vars, escapeURL); + int error = 0 + || templateRender(file, template, vars, escapeURL) + || htmlReplyCc(file, true, envelope->to) + || htmlReplyCc(file, false, envelope->cc) + || fclose(file); + if (error) err(EX_OSERR, "open_memstream"); + return buf; } int htmlMessageNav(FILE *file, const struct Envelope *envelope) { @@ -528,7 +552,9 @@ int htmlIndexOpen(FILE *file) { [+subscribe] subscribe [-] + [+mailto] write + [-]
-- cgit 1.4.1