Use base64 encoding for permalinks in bbs rooms, otherwise google+ mangles them
authorArt Cancro <ajc@uncensored.citadel.org>
Tue, 20 Sep 2011 16:31:48 +0000 (12:31 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 18 Oct 2011 18:56:17 +0000 (20:56 +0200)
webcit/msg_renderers.c
webcit/static/t/view_message.html

index a01e9e9b1a92b9adaed060fc0637891d8c1c581e..10e20e90d2f2bfda4cf5baf2be49bf54f83bc62e 100644 (file)
@@ -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);
index ff63fa155736e3a618dfa275d45b8779806ac67d..c3b37c672f23c2232b4871ca818a5f90fbd68f96 100644 (file)
@@ -2,7 +2,7 @@
 <?!("COND:ROOM:TYPE_IS", 13, #"VIEW_BBS")><a name="<?MAIL:SUMM:N>"></a><??("X", 13)>
 <??("COND:ROOM:TYPE_IS", 12, #"VIEW_WIKI")><!-- skip headers for wiki rooms -->
 <div class="message_header">
-<?!("COND:ROOM:TYPE_IS", 14, #"VIEW_BBS")><a href="/readfwd?go=<?CURRENT_ROOM("U")>?start_reading_at=<?MAIL:SUMM:N>#<?MAIL:SUMM:N>">[#]</a><??("X", 14)>
+<?!("COND:ROOM:TYPE_IS", 14, #"VIEW_BBS")><a href="<?MAIL:SUMM:PERMALINK>">[#]</a><??("X", 14)>
  <span><?MAIL:SUMM:DATEFULL></span>
  <?_("from ")>
  <??("COND:MAIL:ANON",1)>