]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/server/room_functions.c
Changed the arrangement of bytes in the universe
[citadel.git] / webcit-ng / server / room_functions.c
index 92ed577e874ef54516b8943a632306bb121b71a4..8d8ca3bcc5113c670c5a48161a5b630a39d1a858 100644 (file)
@@ -111,18 +111,21 @@ void json_mailbox(struct http_transaction *h, struct ctdlsession *c) {
        ctdl_readline(c, buf, sizeof(buf));
        if (buf[0] == '1') {
                while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))) {
-                       utf8ify_rfc822_string(buf);
                        JsonValue *jmsg = NewJsonObject(HKEY("message"));
                        JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgnum"), extract_long(buf, 0)));
                        JsonObjectAppend(jmsg, NewJsonNumber(HKEY("time"), extract_long(buf, 1)));
                        extract_token(field, buf, 2, '|', sizeof field);
+                       utf8ify_rfc822_string(field);
                        JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("author"), field, -1));
                        extract_token(field, buf, 4, '|', sizeof field);
+                       utf8ify_rfc822_string(field);
                        JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("addr"), field, -1));
                        extract_token(field, buf, 5, '|', sizeof field);
+                       utf8ify_rfc822_string(field);
                        JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("subject"), field, -1));
                        JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgidhash"), extract_long(buf, 6)));
                        extract_token(field, buf, 7, '|', sizeof field);
+                       utf8ify_rfc822_string(field);
                        JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("references"), field, -1));
                        JsonArrayAppend(j, jmsg);               // add the message to the array
                }
@@ -262,7 +265,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
        // A sixth component in the URL can be one of two things:
        // (1) a MIME part specifier, in which case the client wants to download that component within the message
        // (2) a content-type, in which ase the client wants us to try to render it a certain way
-       if (num_tokens(h->url, '/') == 6) {
+       if (num_tokens(h->url, '/') >= 6) {
                extract_token(buf, h->url, 5, '/', sizeof buf);
                if (!IsEmptyStr(buf)) {
                        if (!strcasecmp(buf, "json")) {
@@ -419,9 +422,10 @@ void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c)
                if (msglist) {
                        int i;
                        for (i = 0; (msglist[i] > 0); ++i) {
-                               if ((i % 10) == 0)
+                               if ((i % 10) == 0) {
                                        syslog(LOG_DEBUG, "PROPFIND enumerated %d messages", i);
-                               e = NULL;       // EUID gets stored here
+                               }
+                               e = NULL;               // EUID gets stored here
                                timestamp = 0;
 
                                char cbuf[1024];
@@ -679,7 +683,7 @@ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
                }
                return;
        }
-       if (num_tokens(h->url, '/') == 6) {
+       if (num_tokens(h->url, '/') >= 6) {
                object_in_room(h, c);   //      /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component
                return;
        }