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 | |
parent | 8ad057518fc70b8eb1ac7eaabb01a7950e3f63c0 (diff) | |
download | gsoc2013-evolution-f5ba4dde57c0bd90e16f515f3dacc8a68637b5d5.tar.gz 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')
-rw-r--r-- | camel/ChangeLog | 10 | ||||
-rw-r--r-- | camel/camel-mime-part-utils.c | 3 | ||||
-rw-r--r-- | camel/camel-multipart.c | 29 |
3 files changed, 37 insertions, 5 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index e7fb8aac8f..c9e7424a50 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,13 @@ +2000-05-26 Dan Winship <danw@helixcode.com> + + * 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. + 2000-05-25 Jeffrey Stedfast <fejj@helixcode.com> * providers/imap/camel-imap-store.c (try_connect): Removed diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 94bef5e587..f2b67416ac 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -191,7 +191,8 @@ camel_mime_part_construct_content_from_parser(CamelMimePart *dw, CamelMimeParser d(printf("Creating multi-part\n")); content = (CamelDataWrapper *)camel_multipart_new(); - /* get/set boundary? */ + /* FIXME: use the real boundary? */ + camel_multipart_set_boundary((CamelMultipart *)content, NULL); while (camel_mime_parser_step(mp, &buf, &len) != HSCAN_MULTIPART_END) { camel_mime_parser_unstep(mp); 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); } |