mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 10:22:15 -05:00
Merge pull request #168 from aatdark/aatdark_mime4j072
upgraded Mime4J from 0.7-SNAPSHOT to 0.7.2. Fixes MimeMultipart parser bug (Issue 4455).
This commit is contained in:
commit
a274a3717a
@ -3,12 +3,12 @@
|
|||||||
<classpathentry excluding="**/.svn/**|.svn/**" kind="src" path="src"/>
|
<classpathentry excluding="**/.svn/**|.svn/**" kind="src" path="src"/>
|
||||||
<classpathentry excluding="**/.svn/**|.svn/**" kind="src" path="gen"/>
|
<classpathentry excluding="**/.svn/**|.svn/**" kind="src" path="gen"/>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
<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/commons-io-2.0.1.jar"/>
|
||||||
<classpathentry kind="lib" path="libs/jzlib-1.0.7.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/jutf7-1.0.1-SNAPSHOT.jar"/>
|
||||||
<classpathentry kind="lib" path="libs/htmlcleaner-2.2.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 exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
Binary file not shown.
BIN
libs/apache-mime4j-core-0.7.2.jar
Normal file
BIN
libs/apache-mime4j-core-0.7.2.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
libs/apache-mime4j-dom-0.7.2.jar
Normal file
BIN
libs/apache-mime4j-dom-0.7.2.jar
Normal file
Binary file not shown.
@ -1,6 +1,15 @@
|
|||||||
|
|
||||||
package com.fsck.k9.mail;
|
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.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
@ -11,16 +20,8 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.helper.Contacts;
|
import com.fsck.k9.helper.Contacts;
|
||||||
import com.fsck.k9.helper.Utility;
|
|
||||||
import com.fsck.k9.helper.StringUtils;
|
import com.fsck.k9.helper.StringUtils;
|
||||||
import org.apache.james.mime4j.codec.EncoderUtil;
|
import com.fsck.k9.helper.Utility;
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
public class Address {
|
public class Address {
|
||||||
@ -137,7 +138,8 @@ public class Address {
|
|||||||
}
|
}
|
||||||
List<Address> addresses = new ArrayList<Address>();
|
List<Address> addresses = new ArrayList<Address>();
|
||||||
try {
|
try {
|
||||||
MailboxList parsedList = AddressBuilder.parseAddressList(addressList).flatten();
|
MailboxList parsedList = AddressBuilder.DEFAULT.parseAddressList(addressList).flatten();
|
||||||
|
|
||||||
for (int i = 0, count = parsedList.size(); i < count; i++) {
|
for (int i = 0, count = parsedList.size(); i < count; i++) {
|
||||||
org.apache.james.mime4j.dom.address.Address address = parsedList.get(i);
|
org.apache.james.mime4j.dom.address.Address address = parsedList.get(i);
|
||||||
if (address instanceof Mailbox) {
|
if (address instanceof Mailbox) {
|
||||||
@ -145,13 +147,13 @@ public class Address {
|
|||||||
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
|
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
|
||||||
} else {
|
} else {
|
||||||
Log.e(K9.LOG_TAG, "Unknown address type from Mime4J: "
|
Log.e(K9.LOG_TAG, "Unknown address type from Mime4J: "
|
||||||
+ address.getClass().toString());
|
+ address.getClass().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MimeException pe) {
|
} catch (MimeException pe) {
|
||||||
Log.e(K9.LOG_TAG, "MimeException in Address.parse()", 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
|
//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);
|
return addresses.toArray(EMPTY_ADDRESS_ARRAY);
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,38 @@
|
|||||||
|
|
||||||
package com.fsck.k9.mail.internet;
|
package com.fsck.k9.mail.internet;
|
||||||
|
|
||||||
import com.fsck.k9.mail.*;
|
import java.io.BufferedWriter;
|
||||||
import com.fsck.k9.mail.store.UnavailableStorageException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import org.apache.james.mime4j.stream.BodyDescriptor;
|
import java.io.OutputStream;
|
||||||
import org.apache.james.mime4j.stream.RawField;
|
import java.io.OutputStreamWriter;
|
||||||
import org.apache.james.mime4j.parser.ContentHandler;
|
import java.text.SimpleDateFormat;
|
||||||
import org.apache.james.mime4j.io.EOLConvertingInputStream;
|
import java.util.Date;
|
||||||
import org.apache.james.mime4j.parser.MimeStreamParser;
|
import java.util.LinkedList;
|
||||||
import org.apache.james.mime4j.stream.MimeEntityConfig;
|
import java.util.Locale;
|
||||||
import org.apache.james.mime4j.dom.field.DateTimeField;
|
import java.util.Set;
|
||||||
import org.apache.james.mime4j.dom.field.Field;
|
import java.util.UUID;
|
||||||
import org.apache.james.mime4j.field.DefaultFieldParser;
|
|
||||||
|
|
||||||
import org.apache.james.mime4j.MimeException;
|
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 com.fsck.k9.mail.Address;
|
||||||
import java.text.SimpleDateFormat;
|
import com.fsck.k9.mail.Body;
|
||||||
import java.util.*;
|
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
|
* 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;
|
mBody = null;
|
||||||
|
|
||||||
MimeEntityConfig parserConfig = new MimeEntityConfig();
|
MimeConfig parserConfig = new MimeConfig();
|
||||||
parserConfig.setMaxHeaderLen(-1); // The default is a mere 10k
|
parserConfig.setMaxHeaderLen(-1); // The default is a mere 10k
|
||||||
parserConfig.setMaxLineLen(-1); // The default is 1000 characters. Some MUAs generate
|
parserConfig.setMaxLineLen(-1); // The default is 1000 characters. Some MUAs generate
|
||||||
// REALLY long References: headers
|
// REALLY long References: headers
|
||||||
@ -458,27 +472,8 @@ public class MimeMessage extends Message {
|
|||||||
expect(Part.class);
|
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() {
|
public void endHeader() {
|
||||||
expect(Part.class);
|
expect(Part.class);
|
||||||
@ -552,6 +547,16 @@ public class MimeMessage extends Message {
|
|||||||
public void raw(InputStream is) throws IOException {
|
public void raw(InputStream is) throws IOException {
|
||||||
throw new UnsupportedOperationException("Not supported");
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user