1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-10-31 15:45:08 -04:00

upgraded Mime4J 0.7-SNAPSHOT -> 0.7.2 (fixes MimeMultipart parser bug)

This commit is contained in:
Bernhard Redl 2012-08-15 01:47:57 +02:00
parent 2e454f0af7
commit 89f6c2f6d0
7 changed files with 57 additions and 50 deletions

View File

@ -3,12 +3,12 @@
<classpathentry excluding="**/.svn/**|.svn/**" kind="src" path="src"/>
<classpathentry excluding="**/.svn/**|.svn/**" kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="lib" path="libs/apache-mime4j-core-0.7-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="libs/apache-mime4j-dom-0.7-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="libs/commons-io-2.0.1.jar"/>
<classpathentry kind="lib" path="libs/jzlib-1.0.7.jar"/>
<classpathentry kind="lib" path="libs/jutf7-1.0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="libs/htmlcleaner-2.2.jar"/>
<classpathentry kind="lib" path="libs/apache-mime4j-core-0.7.2.jar"/>
<classpathentry kind="lib" path="libs/apache-mime4j-dom-0.7.2.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,15 @@
package com.fsck.k9.mail;
import java.util.ArrayList;
import java.util.List;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.codec.EncoderUtil;
import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.address.MailboxList;
import org.apache.james.mime4j.field.address.AddressBuilder;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@ -11,16 +20,8 @@ import android.util.Log;
import com.fsck.k9.K9;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.helper.StringUtils;
import org.apache.james.mime4j.codec.EncoderUtil;
import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.address.MailboxList;
import org.apache.james.mime4j.field.address.parser.AddressBuilder;
import org.apache.james.mime4j.MimeException;
import java.util.ArrayList;
import java.util.List;
import com.fsck.k9.helper.Utility;
public class Address {
@ -137,7 +138,8 @@ public class Address {
}
List<Address> addresses = new ArrayList<Address>();
try {
MailboxList parsedList = AddressBuilder.parseAddressList(addressList).flatten();
MailboxList parsedList = AddressBuilder.DEFAULT.parseAddressList(addressList).flatten();
for (int i = 0, count = parsedList.size(); i < count; i++) {
org.apache.james.mime4j.dom.address.Address address = parsedList.get(i);
if (address instanceof Mailbox) {
@ -145,13 +147,13 @@ public class Address {
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
} else {
Log.e(K9.LOG_TAG, "Unknown address type from Mime4J: "
+ address.getClass().toString());
+ address.getClass().toString());
}
}
} catch (MimeException pe) {
Log.e(K9.LOG_TAG, "MimeException in Address.parse()", pe);
//but we do an silent failover : we just use the given string as name with empty address
addresses.add(new Address(null, addressList,false));
addresses.add(new Address(null, addressList, false));
}
return addresses.toArray(EMPTY_ADDRESS_ARRAY);
}

View File

@ -1,24 +1,38 @@
package com.fsck.k9.mail.internet;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.store.UnavailableStorageException;
import org.apache.james.mime4j.stream.BodyDescriptor;
import org.apache.james.mime4j.stream.RawField;
import org.apache.james.mime4j.parser.ContentHandler;
import org.apache.james.mime4j.io.EOLConvertingInputStream;
import org.apache.james.mime4j.parser.MimeStreamParser;
import org.apache.james.mime4j.stream.MimeEntityConfig;
import org.apache.james.mime4j.dom.field.DateTimeField;
import org.apache.james.mime4j.dom.field.Field;
import org.apache.james.mime4j.field.DefaultFieldParser;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.dom.field.DateTimeField;
import org.apache.james.mime4j.dom.field.ParsedField;
import org.apache.james.mime4j.field.DefaultFieldParser;
import org.apache.james.mime4j.io.EOLConvertingInputStream;
import org.apache.james.mime4j.parser.ContentHandler;
import org.apache.james.mime4j.parser.MimeStreamParser;
import org.apache.james.mime4j.stream.BodyDescriptor;
import org.apache.james.mime4j.stream.Field;
import org.apache.james.mime4j.stream.MimeConfig;
import org.apache.james.mime4j.stream.RawField;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart;
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 com.fsck.k9.mail.store.UnavailableStorageException;
/**
* An implementation of Message that stores all of it's metadata in RFC 822 and
@ -73,7 +87,7 @@ public class MimeMessage extends Message {
mBody = null;
MimeEntityConfig parserConfig = new MimeEntityConfig();
MimeConfig parserConfig = new MimeConfig();
parserConfig.setMaxHeaderLen(-1); // The default is a mere 10k
parserConfig.setMaxLineLen(-1); // The default is 1000 characters. Some MUAs generate
// REALLY long References: headers
@ -458,27 +472,8 @@ public class MimeMessage extends Message {
expect(Part.class);
}
public void field(RawField field) {
expect(Part.class);
try {
Field parsedField = DefaultFieldParser.parse(field.getRaw(), null);
((Part)stack.peek()).addHeader(parsedField.getName(), parsedField.getBody().trim());
} catch (MessagingException me) {
throw new Error(me);
} catch (MimeException me) {
throw new Error(me);
}
}
public void field(String fieldData) {
expect(Part.class);
try {
String[] tokens = fieldData.split(":", 2);
((Part)stack.peek()).addHeader(tokens[0], tokens[1].trim());
} catch (MessagingException me) {
throw new Error(me);
}
}
public void endHeader() {
expect(Part.class);
@ -552,6 +547,16 @@ public class MimeMessage extends Message {
public void raw(InputStream is) throws IOException {
throw new UnsupportedOperationException("Not supported");
}
@Override
public void field(Field parsedField) throws MimeException {
expect(Part.class);
try {
((Part)stack.peek()).addHeader(parsedField.getName(), parsedField.getBody().trim());
} catch (MessagingException me) {
throw new Error(me);
}
}
}
/**