imap_fetch.c: output an extra space required before the
authorArt Cancro <ajc@citadel.org>
Thu, 23 Aug 2007 17:00:13 +0000 (17:00 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 23 Aug 2007 17:00:13 +0000 (17:00 +0000)
second and subsequent components of a multipart sequence when
outputting BODYSTRUCTURE.  C-Client (in this case, Asterisk) chokes when
that space isn't there.

citadel/modules/imap/imap_fetch.c

index 49818e4387b5de52b4d3513928d7498b96161e32..1e026ba939a2765345836dda20d82b7d52f98bab 100644 (file)
@@ -774,6 +774,7 @@ void imap_fetch_bodystructure_part(
        size_t i;
        char cbmaintype[128];
        char cbsubtype[128];
+       char iteration[128];
 
        if (cbtype != NULL) if (!IsEmptyStr(cbtype)) have_cbtype = 1;
        if (have_cbtype) {
@@ -785,6 +786,23 @@ void imap_fetch_bodystructure_part(
                strcpy(cbsubtype, "PLAIN");
        }
 
+       /* If this is the second or subsequent part of a multipart sequence,
+        * we need to output another space here.  We do this by obtaining the
+        * last subpart token of the partnum and converting it to a number.
+        */
+       if (strrchr(partnum, '.')) {
+               safestrncpy(iteration, (strrchr(partnum, '.')+1), sizeof iteration);
+       }
+       else {
+               safestrncpy(iteration, partnum, sizeof iteration);
+       }
+       if (atoi(iteration) > 1) {
+               cprintf(" ");
+       }
+
+
+       /* output loop */
+
        cprintf("(");
        imap_strout(cbmaintype);
        cprintf(" ");