summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-04-22 22:22:38 -0400
committerJune McEnroe <june@causal.agency>2021-04-22 22:22:38 -0400
commit0d0033ea430ac2a9c9fc2c4c894ad197a6835dd3 (patch)
tree2caae11a5177db59386423a81e0dcec7ecd25522
parentFix handling groups in address lists (diff)
downloadbubger-0d0033ea430ac2a9c9fc2c4c894ad197a6835dd3.tar.gz
bubger-0d0033ea430ac2a9c9fc2c4c894ad197a6835dd3.zip
Don't URL-encode fragment links
Seems that actually makes them not work correctly when they contain
weird things.
Diffstat (limited to '')
-rw-r--r--html.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/html.c b/html.c
index 5104667..981dc4c 100644
--- a/html.c
+++ b/html.c
@@ -91,14 +91,6 @@ htmlAddressList(FILE *file, const char *name, struct AddressList list) {
 	return templateRender(file, Q(</div>), NULL, NULL);
 }
 
-static char *htmlFragment(const char *messageID) {
-	struct Variable vars[] = {
-		{ "messageID", messageID },
-		{0},
-	};
-	return templateString("#[messageID]", vars, escapeURL);
-}
-
 static char *htmlMbox(const char *messageID) {
 	struct Variable vars[] = {
 		{ "messageID", messageID },
@@ -155,40 +147,35 @@ static char *htmlReply(const struct Envelope *envelope) {
 }
 
 int htmlMessageNav(FILE *file, const struct Envelope *envelope) {
-	char *parent = envelope->inReplyTo
-		? htmlFragment(envelope->inReplyTo)
-		: NULL;
 	char *mbox = htmlMbox(envelope->messageID);
 	char *reply = htmlReply(envelope);
 	const char *template = Q(
 		<nav>
 			[+parent]
-			<a href="[parent]">parent</a>
+			<a href="#[parent]">parent</a>
 			[-]
 			<a href="[mbox]">download</a>
 			<a href="[reply]">reply</a>
 		</nav>
 	);
 	struct Variable vars[] = {
-		{ "parent", parent },
+		{ "parent", envelope->inReplyTo },
 		{ "mbox", mbox },
 		{ "reply", reply },
 		{0},
 	};
 	int error = templateRender(file, template, vars, escapeXML);
-	free(parent);
 	free(mbox);
 	free(reply);
 	return error;
 }
 
 int htmlMessageOpen(FILE *file, const struct Envelope *envelope, bool nested) {
-	char *fragment = htmlFragment(envelope->messageID);
 	char *mailto = htmlMailto(envelope->from);
 	const char *template = Q(
 		<article class="message" id="[messageID]">
 		<header>
-			<h2 class="Subject"><a href="[fragment]">[subject]</a></h2>
+			<h2 class="Subject"><a href="#[messageID]">[subject]</a></h2>
 			<div class="From">
 				From: <a href="[mailto]">[from]</a>
 				<time datetime="[utc]">[date]</time>
@@ -196,7 +183,6 @@ int htmlMessageOpen(FILE *file, const struct Envelope *envelope, bool nested) {
 	);
 	struct Variable vars[] = {
 		{ "messageID", envelope->messageID },
-		{ "fragment", fragment },
 		{ "subject", envelope->subject },
 		{ "mailto", mailto },
 		{ "from", addressName(envelope->from) },
@@ -210,7 +196,6 @@ int htmlMessageOpen(FILE *file, const struct Envelope *envelope, bool nested) {
 		|| htmlAddressList(file, "Cc", envelope->cc)
 		|| (nested ? 0 : htmlMessageNav(file, envelope))
 		|| templateRender(file, Q(</header>), NULL, NULL);
-	free(fragment);
 	free(mailto);
 	return error;
 }