Skip to content

Commit

Permalink
Merge pull request #1512 from k9mail/use-mime4j-bodydescriptor
Browse files Browse the repository at this point in the history
Use MIME4J's BodyDescriptor instead of reading Content-Type header ourselves
  • Loading branch information
cketti authored Jul 24, 2016
2 parents df761b9 + 600537f commit 2abcbf9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package com.fsck.k9.mail.internet;


import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -9,14 +10,22 @@
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;

import android.support.annotation.NonNull;

import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.CompositeBody;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.field.DateTimeField;
Expand All @@ -29,15 +38,6 @@
import org.apache.james.mime4j.stream.MimeConfig;
import org.apache.james.mime4j.util.MimeUtil;

import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.CompositeBody;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;

/**
* An implementation of Message that stores all of it's metadata in RFC 822 and
* RFC 2045 style headers.
Expand Down Expand Up @@ -530,9 +530,8 @@ public void startMultipart(BodyDescriptor bd) throws MimeException {

Part e = (Part)stack.peek();
try {
String contentType = e.getContentType();
String mimeType = MimeUtility.getHeaderParameter(contentType, null);
String boundary = MimeUtility.getHeaderParameter(contentType, "boundary");
String mimeType = bd.getMimeType();
String boundary = bd.getBoundary();
MimeMultipart multiPart = new MimeMultipart(mimeType, boundary);
e.setBody(multiPart);
stack.addFirst(multiPart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.fsck.k9.mail.internet.MimeBodyPart;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mailstore.util.FileFactory;
import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.MimeException;
Expand Down Expand Up @@ -150,9 +149,8 @@ public void epilogue(InputStream is) throws MimeException, IOException {
public void startMultipart(BodyDescriptor bd) throws MimeException {
Part part = (Part) stack.peek();
try {
String contentType = part.getContentType();
String mimeType = MimeUtility.getHeaderParameter(contentType, null);
String boundary = MimeUtility.getHeaderParameter(contentType, "boundary");
String mimeType = bd.getMimeType();
String boundary = bd.getBoundary();

MimeMultipart multipart = new MimeMultipart(mimeType, boundary);
part.setBody(multipart);
Expand Down

0 comments on commit 2abcbf9

Please sign in to comment.