+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
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
void trim_subject_for_compare(gchar *str)
{
gchar *srcp;
- int skip;
eliminate_parenthesis(str, '[', ']');
eliminate_parenthesis(str, '(', ')');
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);
+}
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__ */
/* 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);
NULL
};
-static char *create_boundary (void);
-
static void sig_expiration_check (GString *str,
GpgmeCtx ctx,
GpgmeKey key,
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);
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;
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 */