summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-09 22:51:09 -0400
committerJune McEnroe <june@causal.agency>2020-04-09 22:51:09 -0400
commit789eb08b07695808f738b6fade1894bdc681940c (patch)
tree1ae7644b8be36451fe981e81b54356dbb05f6262
parentMove export code to export.c (diff)
downloadbubger-789eb08b07695808f738b6fade1894bdc681940c.tar.gz
bubger-789eb08b07695808f738b6fade1894bdc681940c.zip
URL encode the fragment link
-rw-r--r--html.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/html.c b/html.c
index e404434..f078b75 100644
--- a/html.c
+++ b/html.c
@@ -30,7 +30,7 @@ static const char *Mailto = {
 static const char *Summary = TEMPLATE(
 	<details class="message" id="[messageID]">
 	<summary>
-		<h1 class="subject"><a href="#[messageID]">[subject]</a></h1>
+		<h1 class="subject"><a href="[fragment]">[subject]</a></h1>
 		<address class="from"><a href="[mailto]">[from]</a></address>
 		<time datetime="[utc]">[date]</time>
 	</summary>
@@ -41,6 +41,12 @@ static const char *Address = TEMPLATE(
 );
 
 int htmlEnvelope(FILE *file, const struct Envelope *envelope) {
+	struct Variable fragmentVars[] = {
+		{ "messageID", envelope->messageID },
+		{0},
+	};
+	char *fragment = templateURL("#[messageID]", fragmentVars);
+
 	struct Variable mailtoVars[] = {
 		{ "mailbox", envelope->replyTo.mailbox },
 		{ "host", envelope->replyTo.host },
@@ -62,6 +68,7 @@ int htmlEnvelope(FILE *file, const struct Envelope *envelope) {
 
 	struct Variable summaryVars[] = {
 		{ "messageID", envelope->messageID },
+		{ "fragment", fragment },
 		{ "subject", envelope->subject },
 		{ "mailto", mailto },
 		{ "from", from },
@@ -70,6 +77,7 @@ int htmlEnvelope(FILE *file, const struct Envelope *envelope) {
 		{0},
 	};
 	int error = templateRender(file, Summary, summaryVars, escapeXML);
+	free(fragment);
 	free(mailto);
 	if (error) return error;