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
This commit is contained in:
Dan Winship
2000-05-26 14:46:13 +00:00
parent 8ad057518f
commit f5ba4dde57
3 changed files with 37 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}