Bug 1571481 - Improve multipart/alternative.

w/ Fixup for 1464056 - Follow-up: rename pref to align with mailnews.p7m_external (which was already in 52.x but missing a single line)

Tag #1311
This commit is contained in:
Gaming4JC 2019-12-02 23:47:40 -05:00 • committed by Roy Tam
commit 5199f3f3b8
3 changed files with 25 additions and 20 deletions

View file

@ -725,21 +725,20 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs,
else if (!PL_strcasecmp(content_type, APPLICATION_XPKCS7_MIME) else if (!PL_strcasecmp(content_type, APPLICATION_XPKCS7_MIME)
|| !PL_strcasecmp(content_type, APPLICATION_PKCS7_MIME)) { || !PL_strcasecmp(content_type, APPLICATION_PKCS7_MIME)) {
if (Preferences::GetBool("mailnews.p7m_subparts_external", false) && if (Preferences::GetBool("mailnews.p7m_subparts_external", true) &&
opts->is_child) { opts->is_child) {
// We do not allow encrypted parts except as top level. // We do not allow encrypted parts except as top level.
// Allowing them would leak the plain text in case the part is // Allowing them would leak the plain text in case the part is
// cleverly hidden and the decrypted content gets included in // cleverly hidden and the decrypted content gets included in
// replies and forwards. // replies and forwards.
clazz = (MimeObjectClass *)&mimeSuppressedCryptoClass; clazz = (MimeObjectClass *)&mimeSuppressedCryptoClass;
return clazz; } else {
} char *ct =
hdrs ? MimeHeaders_get(hdrs, HEADER_CONTENT_TYPE, false, false)
char *ct = (hdrs ? MimeHeaders_get(hdrs, HEADER_CONTENT_TYPE, : nullptr;
false, false) char *st =
: nullptr); ct ? MimeHeaders_get_parameter(ct, "smime-type", nullptr, nullptr)
char *st = (ct ? MimeHeaders_get_parameter(ct, "smime-type", NULL, NULL) : nullptr;
: nullptr);
/* by default, assume that it is an encrypted message */ /* by default, assume that it is an encrypted message */
clazz = (MimeObjectClass *)&mimeEncryptedCMSClass; clazz = (MimeObjectClass *)&mimeEncryptedCMSClass;
@ -747,9 +746,8 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs,
/* if the smime-type parameter says that it's a certs-only or /* if the smime-type parameter says that it's a certs-only or
compressed file, then show it as an attachment, however compressed file, then show it as an attachment, however
(MimeEncryptedCMS doesn't handle these correctly) */ (MimeEncryptedCMS doesn't handle these correctly) */
if (st && if (st && (!PL_strcasecmp(st, "certs-only") ||
(!PL_strcasecmp(st, "certs-only") || !PL_strcasecmp(st, "compressed-data")))
!PL_strcasecmp(st, "compressed-data")))
clazz = (MimeObjectClass *)&mimeExternalObjectClass; clazz = (MimeObjectClass *)&mimeExternalObjectClass;
else { else {
/* look at the file extension... less reliable, but still covered /* look at the file extension... less reliable, but still covered
@ -763,14 +761,14 @@ mime_find_class (const char *content_type, MimeHeaders *hdrs,
prefBranch->GetBoolPref("mailnews.p7m_external", &p7mExternal); prefBranch->GetBoolPref("mailnews.p7m_external", &p7mExternal);
if (suf && if (suf &&
((!PL_strcasecmp(suf, ".p7m") && p7mExternal) || ((!PL_strcasecmp(suf, ".p7m") && p7mExternal) ||
!PL_strcasecmp(suf, ".p7c") || !PL_strcasecmp(suf, ".p7c") || !PL_strcasecmp(suf, ".p7z")))
!PL_strcasecmp(suf, ".p7z")))
clazz = (MimeObjectClass *)&mimeExternalObjectClass; clazz = (MimeObjectClass *)&mimeExternalObjectClass;
} }
PR_Free(name); PR_Free(name);
} }
PR_Free(st); PR_Free(st);
PR_Free(ct); PR_Free(ct);
}
} }
#endif #endif
/* A few types which occur in the real world and which we would otherwise /* A few types which occur in the real world and which we would otherwise

View file

@ -282,6 +282,10 @@ MimeMultipartAlternative_parse_eof (MimeObject *obj, bool abort_p)
static int static int
MimeMultipartAlternative_create_child(MimeObject *obj) MimeMultipartAlternative_create_child(MimeObject *obj)
{ {
if (obj->options) {
obj->options->is_child = true;
}
MimeMultipart *mult = (MimeMultipart *) obj; MimeMultipart *mult = (MimeMultipart *) obj;
MimeMultipartAlternative *malt = (MimeMultipartAlternative *) obj; MimeMultipartAlternative *malt = (MimeMultipartAlternative *) obj;

View file

@ -90,6 +90,9 @@ MimeSunAttachment_check_boundary(MimeObject *obj, const char *line,
static int static int
MimeSunAttachment_create_child(MimeObject *obj) MimeSunAttachment_create_child(MimeObject *obj)
{ {
if (obj->options) {
obj->options->is_child = true;
}
MimeMultipart *mult = (MimeMultipart *) obj; MimeMultipart *mult = (MimeMultipart *) obj;
int status = 0; int status = 0;