]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/network/serv_network.c
more tiny merge misses
[citadel.git] / citadel / modules / network / serv_network.c
index 4518740bf1ac9d00754940659cfbe3070abb6f5b..7506a1abf372267158b71c6f6a918247353bed8a 100644 (file)
@@ -679,8 +679,9 @@ void network_spool_msg(long msgnum, void *userdata) {
                 */
                msg = CtdlFetchMessage(msgnum, 1);
                if (msg != NULL) {
-                       int len, rlen;
+                       int rlen;
                        char *pCh;
+                       StrBuf *Subject, *FlatSubject;
 
                        if (msg->cm_fields['V'] == NULL){
                                /* local message, no enVelope */
@@ -709,39 +710,53 @@ void network_spool_msg(long msgnum, void *userdata) {
 
                        /* Prepend "[List name]" to the subject */
                        if (msg->cm_fields['U'] == NULL) {
-                               msg->cm_fields['U'] = strdup("(no subject)");
+                               Subject = NewStrBufPlain(HKEY("(no subject)"));
                        }
-                       
-                       len  = strlen(msg->cm_fields['U']);
+                       else {
+                               Subject = NewStrBufPlain(msg->cm_fields['U'], -1);
+                       }
+                       FlatSubject = NewStrBufPlain(NULL, StrLength(Subject));
+                       StrBuf_RFC822_to_Utf8(FlatSubject, Subject, NULL, NULL);
+
                        rlen = strlen(CC->room.QRname);
-                       pCh  = strstr(msg->cm_fields['U'], CC->room.QRname);
+                       pCh  = strstr(ChrPtr(FlatSubject), CC->room.QRname);
                        if ((pCh == NULL) ||
                            (*(pCh + rlen) != ']') ||
-                           (pCh == msg->cm_fields['U']) ||
+                           (pCh == ChrPtr(FlatSubject)) ||
                            (*(pCh - 1) != '[')
                                )
                        {
-                               char *pBuff;
+                               StrBuf *tmp;
+                               StrBufPlain(Subject, HKEY("["));
+                               StrBufAppendBufPlain(Subject, CC->room.QRname, rlen, 0);
+                               StrBufAppendBufPlain(Subject, HKEY("] "), 0);
+                               StrBufAppendBuf(Subject, FlatSubject, 0);
+                               tmp = Subject;  Subject = FlatSubject;  FlatSubject = tmp; /* so we can free the right one... */
+                               StrBufRFC2047encode(&Subject, FlatSubject);
+                       }
+                       
+                       if (msg->cm_fields['U'] != NULL)
+                               free (msg->cm_fields['U']);
+                       msg->cm_fields['U'] = SmashStrBuf(&Subject);
 
-                               rlen += len + 4;
-                               pBuff = malloc (rlen * sizeof(char));
+                       FreeStrBuf(&FlatSubject);
 
-                               snprintf(pBuff, rlen, "[%s] %s", CC->room.QRname, msg->cm_fields['U']);
-                               free(msg->cm_fields['U']);
-                               msg->cm_fields['U'] = pBuff;
-                       }
                        /* else we won't modify the buffer, since the roomname is already here. */
 
-                       /* if we don't already have a 'reply to' field, put our roomname in. */
-                       if (msg->cm_fields['K'] == NULL) {
-                               msg->cm_fields['K'] = malloc(256);
-                               snprintf(msg->cm_fields['K'], 256,
-                                        "room_%s@%s", CC->room.QRname,
-                                        config.c_fqdn);
-                               for (i=0; msg->cm_fields['K'][i]; ++i) {
-                                       if (isspace(msg->cm_fields['K'][i])) {
-                                               msg->cm_fields['K'][i] = '_';
-                                       }
+                       /* Set the recipient of the list message to the
+                        * email address of the room itself.
+                        * FIXME ... I want to be able to pick any address
+                        */
+                       if (msg->cm_fields['R'] != NULL) {
+                               free(msg->cm_fields['R']);
+                       }
+                       msg->cm_fields['R'] = malloc(256);
+                       snprintf(msg->cm_fields['R'], 256,
+                               "room_%s@%s", CC->room.QRname,
+                               config.c_fqdn);
+                       for (i=0; msg->cm_fields['R'][i]; ++i) {
+                               if (isspace(msg->cm_fields['R'][i])) {
+                                       msg->cm_fields['R'][i] = '_';
                                }
                        }
 
@@ -2436,7 +2451,7 @@ void cmd_netp(char *cmdbuf)
                        "An unknown Citadel server called \"%s\" attempted to connect from %s [%s].\n",
                        node, CC->cs_host, CC->cs_addr
                );
-               syslog(LOG_WARNING, err_buf);
+               syslog(LOG_WARNING, "%s", err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking.");
                return;
@@ -2447,7 +2462,7 @@ void cmd_netp(char *cmdbuf)
                        "A Citadel server at %s [%s] failed to authenticate as network node \"%s\".\n",
                        CC->cs_host, CC->cs_addr, node
                );
-               syslog(LOG_WARNING, err_buf);
+               syslog(LOG_WARNING, "%s", err_buf);
                cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
                CtdlAideMessage(err_buf, "IGNet Networking.");
                return;