Commit b024636b authored by Hussein's avatar Hussein

P4A-956 Fix attachment parsing to deal with plain/text as attachments.

parent 471cc2e2
......@@ -70,7 +70,7 @@ class PEpMessageBuilder {
if(!(b instanceof MimeMultipart)) { //FIXME: Don't do this assumption (if not Multipart then plain or html text)
String disposition = MimeUtility.unfoldAndDecode(mm.getDisposition());
if (("attachment".equalsIgnoreCase(MessageExtractor.getContentDisposition(mm)))) {
if ((isAnAttachment(mm))) {
Log.i("PEpMessageBuilder", "addBody 1 " + disposition);
String filename = MimeUtility.getHeaderParameter(disposition, "filename");
addAttachment(attachments, mm.getContentType(), filename, PEpUtils.extractBodyContent(b));
......@@ -122,7 +122,7 @@ class PEpMessageBuilder {
//FIXME> Deal with non text and non multipart message and non attachments
boolean plain = mbp.isMimeType("text/plain");
if (plain || mbp.isMimeType("text/html")) {
if (!isAnAttachment(mbp) && (plain || mbp.isMimeType("text/html"))) {
String charset = getMessageCharset();
String text = new String(PEpUtils.extractBodyContent(mbp_body), charset);
......@@ -244,7 +244,7 @@ class PEpMessageBuilder {
if (part.getMimeType().equalsIgnoreCase("message/rfc822")) return "ForwardedMessage.eml";
if (filename == null) {
String disposition = MimeUtility.unfoldAndDecode(part.getDisposition());
if (("attachment".equalsIgnoreCase(MessageExtractor.getContentDisposition(part)))) {
if (isAnAttachment(part)) {
Log.i("PEpMessageBuilder", "addBody 1 " + disposition);
filename = MimeUtility.getHeaderParameter(disposition, "filename");
}
......@@ -253,4 +253,8 @@ class PEpMessageBuilder {
return filename != null ? filename : DEFAULT_FILENAME;
}
private boolean isAnAttachment(Part part) {
return "attachment".equalsIgnoreCase(MessageExtractor.getContentDisposition(part));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment