From 5dd116cf07d991263431624a735698374c6fb692 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 20 Sep 2011 12:31:48 -0400 Subject: [PATCH] Use base64 encoding for permalinks in bbs rooms, otherwise google+ mangles them --- webcit/msg_renderers.c | 16 ++++++++++++++++ webcit/static/t/view_message.html | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index a01e9e9b1..10e20e90d 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -865,6 +865,21 @@ void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP) } +void tmplput_MAIL_SUMM_PERMALINK(StrBuf *Target, WCTemplputParams *TP) +{ + message_summary *Msg = (message_summary*) CTX; + char perma_link[1024]; + char encoded_link[1024]; + + strcpy(perma_link, "/readfwd?go="); + urlesc(&perma_link[12], sizeof(perma_link) - 12, (char *)ChrPtr(WC->CurRoom.name) ); + sprintf(&perma_link[strlen(perma_link)], "?start_reading_at=%ld#%ld", Msg->msgnum, Msg->msgnum); + + + CtdlEncodeBase64(encoded_link, perma_link, strlen(perma_link), 0); + StrBufAppendPrintf(Target, "/B64%s", encoded_link); +} + int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP) { @@ -1453,6 +1468,7 @@ InitModule_MSGRENDERERS RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, NULL, CTX_MAILSUM); RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, NULL, CTX_MAILSUM); RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, NULL, CTX_MAILSUM); + RegisterNamespace("MAIL:SUMM:PERMALINK", 0, 0, tmplput_MAIL_SUMM_PERMALINK, NULL, CTX_MAILSUM); RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, NULL, CTX_MAILSUM); RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, NULL, CTX_MAILSUM); RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, NULL, CTX_MAILSUM); diff --git a/webcit/static/t/view_message.html b/webcit/static/t/view_message.html index ff63fa155..c3b37c672 100644 --- a/webcit/static/t/view_message.html +++ b/webcit/static/t/view_message.html @@ -2,7 +2,7 @@
-?start_reading_at=#">[#] +[#] -- 2.30.2