0.9.4claws61
authorChristoph Hohmann <reboot@gmx.ch>
Thu, 4 Sep 2003 20:35:23 +0000 (20:35 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Thu, 4 Sep 2003 20:35:23 +0000 (20:35 +0000)
* src/compose.c
* src/rfc2015.c
* src/common/utils.[ch]
        add util function to create mime boundary and use it
        in compose and gpg code

ChangeLog.claws
configure.ac
src/common/utils.c
src/common/utils.h
src/compose.c
src/rfc2015.c

index f29fdb3dd5979ac59a709b594cbc63e40dfe3f14..03eafb58740eddb740c82d6d28e78e31fb81d17b 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-03 [christoph] 0.9.4claws61
+
+       * src/compose.c
+       * src/rfc2015.c
+       * src/common/utils.[ch]
+               add util function to create mime boundary and use it
+               in compose and gpg code
+
 2003-09-03 [alfons]    0.9.4claws60
 
        * src/folder.c
index 264930a059a05ebf4943a8340a7c7c524f126722..2f4f72a82fe3b9fa85b83f0ce3bea9a3df29108a 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=60
+EXTRA_VERSION=61
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 32821099e27d0d35ad029a14591cef115afee5a8..d5e861f527bca8e3d6f833ec2f96d1f101522c41 100644 (file)
@@ -576,7 +576,6 @@ gint subject_compare_for_sort(const gchar *s1, const gchar *s2)
 void trim_subject_for_compare(gchar *str)
 {
        gchar *srcp;
-       int skip;
 
        eliminate_parenthesis(str, '[', ']');
        eliminate_parenthesis(str, '(', ')');
@@ -3595,3 +3594,65 @@ gchar *generate_msgid(const gchar *address, gchar *buf, gint len)
        g_free(addr);
        return buf;
 }
+
+/**
+ * Create a new boundary in a way that it is very unlikely that this
+ * will occur in the following text.  It would be easy to ensure
+ * uniqueness if everything is either quoted-printable or base64
+ * encoded (note that conversion is allowed), but because MIME bodies
+ * may be nested, it may happen that the same boundary has already
+ * been used. We avoid scanning the message for conflicts and hope the
+ * best.
+ *
+ *   boundary := 0*69<bchars> bcharsnospace
+ *   bchars := bcharsnospace / " "
+ *   bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
+ *                    "+" / "_" / "," / "-" / "." /
+ *                    "/" / ":" / "=" / "?"  
+ *
+ * ":" and "," removed because of buggy MTAs
+ */
+
+gchar *generate_mime_boundary(void)
+{
+       static gchar tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                            "abcdefghijklmnopqrstuvwxyz" 
+                            "1234567890'()+_./=?";
+       gchar bufuniq[17];
+       gchar bufdate[BUFFSIZE];
+       int i, equal;
+       int pid;
+
+       pid = getpid();
+
+       /* We make the boundary depend on the pid, so that all running
+        * processed generate different values even when they have been
+        * started within the same second and srand48(time(NULL)) has been
+        * used.  I can't see whether this is really an advantage but it
+        * doesn't do any harm.
+        */
+       equal = -1;
+       for (i = 0; i < sizeof(bufuniq) - 1; i++) {
+               bufuniq[i] = tbl[(lrand48() ^ pid) % (sizeof(tbl) - 1)];        /* fill with random */
+               if (bufuniq[i] == '=' && equal == -1)
+                       equal = i;
+       }
+       bufuniq[i] = 0;
+
+       /* now make sure that we do have the sequence "=." in it which cannot
+        * be matched by quoted-printable or base64 encoding */
+       if (equal != -1 && (equal + 1) < i)
+               bufuniq[equal + 1] = '.';
+       else {
+               bufuniq[0] = '=';
+               bufuniq[1] = '.';
+       }
+
+       get_rfc822_date(bufdate, sizeof(bufdate));
+       subst_char(bufdate, ' ', '_');
+       subst_char(bufdate, ',', '_');
+       subst_char(bufdate, ':', '_');
+
+       return g_strdup_printf("Multipart_%s_%s",
+                              bufdate, bufuniq);
+}
index 118cda31d17e185be81559e1563d1b1588775c61..629fd219fe7d4035eebdda320884ee846c355f96 100644 (file)
@@ -426,6 +426,7 @@ guint g_stricase_hash       (gconstpointer gptr);
 gint g_stricase_equal  (gconstpointer gptr1, gconstpointer gptr2);
 gint g_int_compare     (gconstpointer a, gconstpointer b);
 
-gchar *generate_msgid  (const gchar *address, gchar *buf, gint len);
+gchar *generate_msgid          (const gchar *address, gchar *buf, gint len);
+gchar *generate_mime_boundary  (void);
 
 #endif /* __UTILS_H__ */
index 8ae372ffa2fcb481d3102ecd59706b73ac0d4b7e..a9c28b4e049e019e08857103bc7459531aa566aa 100644 (file)
@@ -4287,12 +4287,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        /* MIME */
        fprintf(fp, "Mime-Version: 1.0\n");
        if (compose_use_attach(compose)) {
-               get_rfc822_date(buf, sizeof(buf));
-               subst_char(buf, ' ', '_');
-               subst_char(buf, ',', '_');
-               subst_char(buf, ':', '_');
-               compose->boundary = g_strdup_printf("Multipart_%s_%08x",
-                                                   buf, (guint)compose);
+               compose->boundary = generate_mime_boundary();
                fprintf(fp,
                        "Content-Type: multipart/mixed;\n"
                        " boundary=\"%s\"\n", compose->boundary);
index 4c2cc42a18d0cdb1cfb22ecd594919aada5fbcce..36cda74a18f5e09d6739329d8c44695152da58f8 100644 (file)
@@ -61,8 +61,6 @@ static char *mime_version_name[] = {
     NULL
 };
 
-static char *create_boundary           (void);
-
 static void sig_expiration_check       (GString        *str,
                                         GpgmeCtx        ctx,
                                         GpgmeKey        key, 
@@ -831,7 +829,7 @@ rfc2015_encrypt (const char *file, GSList *recp_list, gboolean ascii_armored)
     GpgmeRecipients rset = NULL;
     size_t nread;
     int mime_version_seen = 0;
-    char *boundary = create_boundary ();
+    char *boundary = generate_mime_boundary ();
 
     /* Create the list of recipients */
     rset = gpgmegtk_recipient_selection (recp_list);
@@ -1163,7 +1161,7 @@ rfc2015_sign (const char *file, GSList *key_list)
     GpgmeData sigdata = NULL;
     size_t nread;
     int mime_version_seen = 0;
-    char *boundary = create_boundary ();
+    char *boundary = generate_mime_boundary ();
     char *micalg = NULL;
     char *siginfo;
 
@@ -1437,59 +1435,4 @@ failure:
     return -1;
 }
 
-
-/****************
- * Create a new boundary in a way that it is very unlikely that this
- * will occur in the following text.  It would be easy to ensure
- * uniqueness if everything is either quoted-printable or base64
- * encoded (note that conversion is allowed), but because MIME bodies
- * may be nested, it may happen that the same boundary has already
- * been used. We avoid scanning the message for conflicts and hope the
- * best.
- *
- *   boundary := 0*69<bchars> bcharsnospace
- *   bchars := bcharsnospace / " "
- *   bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
- *                    "+" / "_" / "," / "-" / "." /
- *                    "/" / ":" / "=" / "?"  
- */
-
-static char *
-create_boundary (void)
-{
-    static char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                       "abcdefghijklmnopqrstuvwxyz"
-                       "1234567890'()+_,./:=?";
-    char buf[17];
-    int i, equal;
-    int pid;
-
-    pid = getpid();
-
-    /* We make the boundary depend on the pid, so that all running
-     * processed generate different values even when they have been
-     * started within the same second and srand48(time(NULL)) has been
-     * used.  I can't see whether this is really an advantage but it
-     * doesn't do any harm.
-     */
-    equal = -1;
-    for(i = 0; i < sizeof(buf) - 1; i++) {
-       buf[i] = tbl[(lrand48() ^ pid) % (sizeof(tbl) - 1)]; /* fill with random */
-       if(buf[i] == '=' && equal == -1)
-           equal = i;
-    }
-    buf[i] = 0;
-
-    /* now make sure that we do have the sequence "=." in it which cannot
-     * be matched by quoted-printable or base64 encoding */
-    if(equal != -1 && (equal+1) < i)
-       buf[equal+1] = '.';
-    else {
-       buf[0] = '=';
-       buf[1] = '.';
-    }
-
-    return g_strdup(buf);
-}
-
 #endif /* USE_GPGME */