diff --git a/email2/emailcommon/src/com/android/emailcommon/internet/MimeUtility.java b/email2/emailcommon/src/com/android/emailcommon/internet/MimeUtility.java index 0c4ffa124..fed601190 100644 --- a/email2/emailcommon/src/com/android/emailcommon/internet/MimeUtility.java +++ b/email2/emailcommon/src/com/android/emailcommon/internet/MimeUtility.java @@ -406,33 +406,11 @@ public class MimeUtility { public static void collectParts(Part part, ArrayList viewables, ArrayList attachments) throws MessagingException { String disposition = part.getDisposition(); - String dispositionType = null; - String dispositionFilename = null; - if (disposition != null) { - dispositionType = MimeUtility.getHeaderParameter(disposition, null); - dispositionFilename = MimeUtility.getHeaderParameter(disposition, "filename"); - } - // An attachment filename can be defined in either the Content-Disposition header - // or the Content-Type header. Content-Disposition is preferred, so we only try - // the Content-Type header as a last resort. - if (dispositionFilename == null) { - String contentType = part.getContentType(); - dispositionFilename = MimeUtility.getHeaderParameter(contentType, "name"); - } - boolean attachmentDisposition = "attachment".equalsIgnoreCase(dispositionType); + String dispositionType = MimeUtility.getHeaderParameter(disposition, null); // If a disposition is not specified, default to "inline" - boolean inlineDisposition = dispositionType == null - || "inline".equalsIgnoreCase(dispositionType); - - // A guess that this part is intended to be an attachment - boolean attachment = attachmentDisposition - || (dispositionFilename != null && !inlineDisposition); - - // A guess that this part is intended to be an inline. - boolean inline = inlineDisposition && (dispositionFilename != null); - - // One or the other - boolean attachmentOrInline = attachment || inline; + boolean inline = dispositionType == null || "inline".equalsIgnoreCase(dispositionType); + // The lower-case mime type + String mimeType = part.getMimeType().toLowerCase(); if (part.getBody() instanceof Multipart) { // If the part is Multipart but not alternative it's either mixed or @@ -462,14 +440,11 @@ public class MimeUtility { // it, pulling any viewables or attachments into the running list. Message message = (Message)part.getBody(); collectParts(message, viewables, attachments); - } else if ((!attachmentOrInline) && ("text/html".equalsIgnoreCase(part.getMimeType()))) { - // If the part is HTML and we got this far, it's a viewable part of a mixed + } else if (inline && (mimeType.startsWith("text") || (mimeType.startsWith("image")))) { + // We'll treat text and images as viewables viewables.add(part); - } else if ((!attachmentOrInline) && ("text/plain".equalsIgnoreCase(part.getMimeType()))) { - // If the part is text and we got this far, it's a viewable part of a mixed - viewables.add(part); - } else if (attachmentOrInline) { - // Finally, if it's an attachment or an inline we will include it as an attachment. + } else { + // Everything else is an attachment. attachments.add(part); } }