]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
Minor formatting cleanup
[citadel.git] / webcit / messages.c
index 4178a91a018006d30e932fd6401d293925c2fdc2..5505602afec8f2b261fbc84cb1c17e48570b73e4 100644 (file)
@@ -332,10 +332,9 @@ int webcit_rfc2047encode(char *target, int maxlen, char *source, long SourceLen)
 
 
 
-/**
- * \brief Look for URL's embedded in a buffer and make them linkable.  We use a
- * target window in order to keep the BBS session in its own window.
- * \param buf the message buffer
+/*
+ * Look for URL's embedded in a buffer and make them linkable.  We use a
+ * target window in order to keep the Citadel session in its own window.
  */
 void url(char *buf)
 {
@@ -778,6 +777,7 @@ void read_message(long msgnum, int printable_view, char *section) {
        char reply_to[512] = "";
        char reply_all[4096] = "";
        char reply_references[1024] = "";
+       char reply_inreplyto[256] = "";
        char now[64] = "";
        int format_type = 0;
        int nhdr = 0;
@@ -850,15 +850,10 @@ void read_message(long msgnum, int printable_view, char *section) {
                        safestrncpy(m_subject, &buf[5], sizeof m_subject);
                }
                if (!strncasecmp(buf, "msgn=", 5)) {
-                       safestrncpy(reply_references, &buf[5], sizeof reply_references);
+                       safestrncpy(reply_inreplyto, &buf[5], sizeof reply_inreplyto);
                }
                if (!strncasecmp(buf, "wefw=", 5)) {
-                       int rrlen = strlen(reply_references);
-                       if (rrlen > 0) {
-                               strcpy(&reply_references[rrlen++], "|");
-                       }
-                       safestrncpy(&reply_references[rrlen], &buf[5],
-                               (sizeof(reply_references) - rrlen) );
+                       safestrncpy(reply_references, &buf[5], sizeof reply_references);
                }
                if (!strncasecmp(buf, "cccc=", 5)) {
                        int len;
@@ -1001,7 +996,16 @@ void read_message(long msgnum, int printable_view, char *section) {
 
        }
 
-       /** Generate a reply-to address */
+       /* Trim down excessively long lists of thread references.  We eliminate the
+        * second one in the list so that the thread root remains intact.
+        */
+       int rrtok = num_tokens(reply_references, '|');
+       int rrlen = strlen(reply_references);
+       if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+               remove_token(reply_references, 1, '|');
+       }
+
+       /* Generate a reply-to address */
        if (!IsEmptyStr(rfca)) {
                if (!IsEmptyStr(from)) {
                        snprintf(reply_to, sizeof(reply_to), "%s <%s>", from, rfca);
@@ -1047,10 +1051,12 @@ void read_message(long msgnum, int printable_view, char *section) {
                                if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
                                urlescputs(m_subject);
                        }
+                       wprintf("?references=");
                        if (!IsEmptyStr(reply_references)) {
-                               wprintf("?references=");
                                urlescputs(reply_references);
+                               urlescputs("|");
                        }
+                       urlescputs(reply_inreplyto);
                        wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Reply"));
                }
 
@@ -1066,10 +1072,12 @@ void read_message(long msgnum, int printable_view, char *section) {
                                        if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
                                        urlescputs(m_subject);
                                }
+                               wprintf("?references=");
                                if (!IsEmptyStr(reply_references)) {
-                                       wprintf("?references=");
                                        urlescputs(reply_references);
+                                       urlescputs("|");
                                }
+                               urlescputs(reply_inreplyto);
                                wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyQuoted"));
                        }
                }
@@ -1087,10 +1095,12 @@ void read_message(long msgnum, int printable_view, char *section) {
                                if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
                                urlescputs(m_subject);
                        }
+                       wprintf("?references=");
                        if (!IsEmptyStr(reply_references)) {
-                               wprintf("?references=");
                                urlescputs(reply_references);
+                               urlescputs("|");
                        }
+                       urlescputs(reply_inreplyto);
                        wprintf("\"><span>[</span>%s<span>]</span></a> ", _("ReplyAll"));
                }