diff options
author | Dan Winship <danw@src.gnome.org> | 2000-05-26 22:46:13 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-05-26 22:46:13 +0800 |
commit | f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5 (patch) | |
tree | 0974689fc9710ed575aacbc4c0f05bb479b10863 /camel/camel-multipart.c | |
parent | 8ad057518fc70b8eb1ac7eaabb01a7950e3f63c0 (diff) | |
download | gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar.gz gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar.bz2 gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar.lz gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar.xz gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar.zst gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.zip |
Don't set a default boundary. Require the caller to do that.
* camel-multipart.c (camel_multipart_init): Don't set a default
boundary. Require the caller to do that.
(set_boundary): if boundary is NULL, generate a "random" boundary.
* camel-mime-part-utils.c
(camel_mime_part_construct_content_from_parser): Add a call to
camel_multipart_set_boundary after creating a new multipart.
svn path=/trunk/; revision=3217
Diffstat (limited to 'camel/camel-multipart.c')
-rw-r--r-- | camel/camel-multipart.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index ea1f7d356f..e28c6542bf 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -32,6 +32,10 @@ #include "camel-multipart.h" #include "camel-mime-part.h" #include "camel-exception.h" +#include "md5-utils.h" + +#include <unistd.h> /* for getpid */ +#include <time.h> /* for time */ #define d(x) @@ -98,7 +102,6 @@ camel_multipart_init (gpointer object, gpointer klass) camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), "multipart/mixed"); - camel_multipart_set_boundary (multipart, "=-=-=-="); multipart->preface = NULL; multipart->postface = NULL; } @@ -356,9 +359,27 @@ static void set_boundary (CamelMultipart *multipart, gchar *boundary) { CamelDataWrapper *cdw = CAMEL_DATA_WRAPPER (multipart); + char *bgen, digest[16], bbuf[27], *p; + int state, save; g_return_if_fail (cdw->mime_type != NULL); + if (!boundary) { + /* Generate a fairly random boundary string. */ + bgen = g_strdup_printf ("%p:%lu:%lu", multipart, + (unsigned long) getpid(), + (unsigned long) time(0)); + md5_get_digest (bgen, strlen (bgen), digest); + g_free (bgen); + strcpy (bbuf, "=-"); + p = bbuf + 2; + state = save = 0; + p += base64_encode_step (digest, 16, p, &state, &save); + *p = '\0'; + + boundary = bbuf; + } + gmime_content_field_set_parameter (cdw->mime_type, "boundary", boundary); } @@ -366,17 +387,17 @@ set_boundary (CamelMultipart *multipart, gchar *boundary) /** * camel_multipart_set_boundary: * @multipart: a CamelMultipart - * @boundary: the message boundary + * @boundary: the message boundary, or %NULL * * Sets the message boundary for @multipart to @boundary. This should * be a string which does not occur anywhere in any of @multipart's - * subparts. + * subparts. If @boundary is %NULL, a randomly-generated boundary will + * be used. **/ void camel_multipart_set_boundary (CamelMultipart *multipart, gchar *boundary) { g_return_if_fail (CAMEL_IS_MULTIPART (multipart)); - g_return_if_fail (boundary != NULL); CMP_CLASS (multipart)->set_boundary (multipart, boundary); } |