diff --git a/mailnews/mime/src/mimemult.cpp b/mailnews/mime/src/mimemult.cpp index 116c7a19deef..29dbc0ae37bc 100644 --- a/mailnews/mime/src/mimemult.cpp +++ b/mailnews/mime/src/mimemult.cpp @@ -315,19 +315,36 @@ MimeMultipart_check_boundary(MimeObject *obj, const char *line, PRInt32 length) line[length-2] == '-') { term_p = PR_TRUE; - length -= 2; } + //looks like we have a separator but first, we need to check it's not for one of the part's children. + MimeContainer *cont = (MimeContainer *) obj; + if (cont->nchildren > 0) + { + MimeObject *kid = cont->children[cont->nchildren-1]; + if (kid) + if (mime_typep(kid, (MimeObjectClass*) &mimeMultipartClass)) + { + //Don't ask the kid to check the boundary if it has already detected a Teminator + MimeMultipart *mult = (MimeMultipart *) kid; + if (mult->state != MimeMultipartEpilogue) + if (MimeMultipart_check_boundary(kid, line, length) != MimeMultipartBoundaryTypeNone) + return MimeMultipartBoundaryTypeNone; + } + } + + if (term_p) + length -= 2; + if (blen == length-2 && !nsCRT::strncmp(line+2, mult->boundary, length-2)) - return (term_p + return (term_p ? MimeMultipartBoundaryTypeTerminator : MimeMultipartBoundaryTypeSeparator); else - return MimeMultipartBoundaryTypeNone; + return MimeMultipartBoundaryTypeNone; } - static int MimeMultipart_create_child(MimeObject *obj) {