2007-11-16 [colin] 3.0.2cvs139
authorColin Leroy <colin@colino.net>
Fri, 16 Nov 2007 17:28:18 +0000 (17:28 +0000)
committerColin Leroy <colin@colino.net>
Fri, 16 Nov 2007 17:28:18 +0000 (17:28 +0000)
* src/compose.c
* src/common/utils.c
* src/common/utils.h
Fix bug 1387, 'Request for --compose to
support multiple attachments'

ChangeLog
PATCHSETS
configure.ac
src/common/utils.c
src/common/utils.h
src/compose.c

index 725924ad0a866770c0e8f8e7520fae3b09fabab7..68c6c1019a3741eacd01beece42e3f3d27587bbf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-16 [colin]     3.0.2cvs139
+
+       * src/compose.c
+       * src/common/utils.c
+       * src/common/utils.h
+               Fix bug 1387, 'Request for --compose to 
+               support multiple attachments'
+
 2007-11-16 [colin]     3.0.2cvs138
 
        * src/news.c
index f1024ef024e63ca6649290236c32f018b1cbebcd..c4eceeb2210d969d51ae11a4ba64ce689a997477 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.395.2.334 -r 1.395.2.335 src/summaryview.c;  cvs diff -u -r 1.1.2.81 -r 1.1.2.82 src/gtk/quicksearch.c;  cvs diff -u -r 1.1.2.16 -r 1.1.2.17 src/gtk/quicksearch.h;  ) > 3.0.2cvs136.patchset
 ( cvs diff -u -r 1.16.2.32 -r 1.16.2.33 src/prefs_display_header.c;  ) > 3.0.2cvs137.patchset
 ( cvs diff -u -r 1.101.2.45 -r 1.101.2.46 src/news.c;  ) > 3.0.2cvs138.patchset
+( cvs diff -u -r 1.382.2.420 -r 1.382.2.421 src/compose.c;  cvs diff -u -r 1.36.2.123 -r 1.36.2.124 src/common/utils.c;  cvs diff -u -r 1.20.2.54 -r 1.20.2.55 src/common/utils.h;  ) > 3.0.2cvs139.patchset
index aeae21386d06a35033a8ddb0bc89078e9a6d0a83..1be509add2c2ebbd27866f462794ac6f9fdb6f5d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=138
+EXTRA_VERSION=139
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 41eebf06ce090399d221253abb01572beee7cd5d..1bc69c9af756432b2c443e977a350b5b109f7d99 100644 (file)
@@ -1512,7 +1512,7 @@ static gchar *decode_uri_gdup(const gchar *encoded_uri)
 }
 
 gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
-                    gchar **subject, gchar **body, gchar **attach)
+                    gchar **subject, gchar **body, gchar ***attach)
 {
        gchar *tmp_mailto;
        gchar *p;
@@ -1520,6 +1520,8 @@ gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
                                          "/etc/passwd",
                                          "/etc/shadow",
                                          NULL };
+       gint num_attach = 0;
+       gchar **my_att = NULL;
 
        Xstrdup_a(tmp_mailto, mailto, return -1);
 
@@ -1535,6 +1537,9 @@ gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
        if (to && !*to)
                *to = decode_uri_gdup(tmp_mailto);
 
+       my_att = g_malloc(sizeof(char *));
+       my_att[0] = NULL;
+
        while (p) {
                gchar *field, *value;
 
@@ -1555,30 +1560,53 @@ gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
 
                if (*value == '\0') continue;
 
-               if (cc && !*cc && !g_ascii_strcasecmp(field, "cc")) {
-                       *cc = decode_uri_gdup(value);
-               } else if (bcc && !*bcc && !g_ascii_strcasecmp(field, "bcc")) {
-                       *bcc = decode_uri_gdup(value);
+               if (cc && !g_ascii_strcasecmp(field, "cc")) {
+                       if (!*cc) {
+                               *cc = decode_uri_gdup(value);
+                       } else {
+                               gchar *tmp = decode_uri_gdup(value);
+                               gchar *new_cc = g_strdup_printf("%s, %s", *cc, tmp);
+                               g_free(*cc);
+                               *cc = new_cc;
+                       }
+               } else if (bcc && !g_ascii_strcasecmp(field, "bcc")) {
+                       if (!*bcc) {
+                               *bcc = decode_uri_gdup(value);
+                       } else {
+                               gchar *tmp = decode_uri_gdup(value);
+                               gchar *new_bcc = g_strdup_printf("%s, %s", *bcc, tmp);
+                               g_free(*bcc);
+                               *bcc = new_bcc;
+                       }
                } else if (subject && !*subject &&
                           !g_ascii_strcasecmp(field, "subject")) {
                        *subject = decode_uri_gdup(value);
                } else if (body && !*body && !g_ascii_strcasecmp(field, "body")) {
                        *body = decode_uri_gdup(value);
-               } else if (attach && !*attach && !g_ascii_strcasecmp(field, "attach")) {
+               } else if (attach && !g_ascii_strcasecmp(field, "attach")) {
                        int i = 0;
-                       *attach = decode_uri_gdup(value);
+                       gchar *tmp = decode_uri_gdup(value);
                        for (; forbidden_uris[i]; i++) {
-                               if (strstr(*attach, forbidden_uris[i])) {
+                               if (strstr(tmp, forbidden_uris[i])) {
                                        g_print("Refusing to attach '%s', potential private data leak\n",
-                                                       *attach);
-                                       g_free(*attach);
-                                       *attach = NULL;
+                                                       tmp);
+                                       g_free(tmp);
+                                       tmp = NULL;
                                        break;
                                }
                        }
+                       if (tmp) {
+                               /* attach is correct */
+                               num_attach++;
+                               printf("realloc my_att %d\n", (num_attach+1));
+                               my_att = g_realloc(my_att, (sizeof(char *))*(num_attach+1));
+                               my_att[num_attach-1] = tmp;
+                               my_att[num_attach] = NULL;
+                       }
                }
        }
 
+       *attach = my_att;
        return 0;
 }
 
index 7689acc0c7ad9e4be69f01750e99eb92c2945742..e94b4ca14624dcc6ca05aa26869165c4f961d4f3 100644 (file)
@@ -345,7 +345,7 @@ gint scan_mailto_url                        (const gchar    *mailto,
                                         gchar         **bcc,
                                         gchar         **subject,
                                         gchar         **body,
-                                        gchar         **attach);
+                                        gchar         ***attach);
 
 /* return static strings */
 const gchar *get_home_dir              (void);
index f08125e77a196fdb3b4c1a7d9d2bc8d25f0768e9..eb27cb5697fe093e6a54083f0f7b4cb8bc55872c 100644 (file)
@@ -2384,7 +2384,7 @@ static void compose_entries_set(Compose *compose, const gchar *mailto)
        gchar *body = NULL;
        gchar *temp = NULL;
        gsize  len = 0;
-       gchar *attach = NULL;
+       gchar **attach = NULL;
        
        scan_mailto_url(mailto, &to, &cc, &bcc, &subject, &body, &attach);
 
@@ -2430,14 +2430,18 @@ static void compose_entries_set(Compose *compose, const gchar *mailto)
        }
 
        if (attach) {
-               gchar *utf8_filename = conv_filename_to_utf8(attach);
-               if (utf8_filename) {
-                       if (compose_attach_append(compose, attach, utf8_filename, NULL)) {
-                               alertpanel_notice(_("The file '%s' has been attached."), attach);
-                       } 
-                       g_free(utf8_filename);
-               } else {
-                       alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+               gint i = 0;
+               while (attach[i] != NULL) {
+                       gchar *utf8_filename = conv_filename_to_utf8(attach[i]);
+                       if (utf8_filename) {
+                               if (compose_attach_append(compose, attach[i], utf8_filename, NULL)) {
+                                       alertpanel_notice(_("The file '%s' has been attached."), utf8_filename);
+                               } 
+                               g_free(utf8_filename);
+                       } else {
+                               alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+                       }
+                       i++;
                }
        }
        g_free(to);
@@ -2445,7 +2449,7 @@ static void compose_entries_set(Compose *compose, const gchar *mailto)
        g_free(bcc);
        g_free(subject);
        g_free(body);
-       g_free(attach);
+       g_strfreev(attach);
 }
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)