am feb9a2c6
: Merge from open-source gingerbread - do not merge
* commit 'feb9a2c6be046cdb328223c5d76e027c07eb1326': Fix a decoding problem on the Email body
This commit is contained in:
commit
8031297202
@ -26,13 +26,12 @@ import com.android.email.mail.Part;
|
|||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.james.mime4j.codec.EncoderUtil;
|
import org.apache.james.mime4j.codec.EncoderUtil;
|
||||||
|
import org.apache.james.mime4j.decoder.Base64InputStream;
|
||||||
import org.apache.james.mime4j.decoder.DecoderUtil;
|
import org.apache.james.mime4j.decoder.DecoderUtil;
|
||||||
import org.apache.james.mime4j.decoder.QuotedPrintableInputStream;
|
import org.apache.james.mime4j.decoder.QuotedPrintableInputStream;
|
||||||
import org.apache.james.mime4j.util.CharsetUtil;
|
import org.apache.james.mime4j.util.CharsetUtil;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Base64;
|
|
||||||
import android.util.Base64InputStream;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -361,7 +360,7 @@ public class MimeUtility {
|
|||||||
in = new QuotedPrintableInputStream(in);
|
in = new QuotedPrintableInputStream(in);
|
||||||
}
|
}
|
||||||
else if ("base64".equalsIgnoreCase(contentTransferEncoding)) {
|
else if ("base64".equalsIgnoreCase(contentTransferEncoding)) {
|
||||||
in = new Base64InputStream(in, Base64.DEFAULT);
|
in = new Base64InputStream(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ import com.android.email.mail.Part;
|
|||||||
import com.android.email.mail.MessageTestUtils.MessageBuilder;
|
import com.android.email.mail.MessageTestUtils.MessageBuilder;
|
||||||
import com.android.email.mail.MessageTestUtils.MultipartBuilder;
|
import com.android.email.mail.MessageTestUtils.MultipartBuilder;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -49,6 +53,16 @@ public class MimeUtilityTest extends TestCase {
|
|||||||
|
|
||||||
/** a string without any unicode */
|
/** a string without any unicode */
|
||||||
private final String SHORT_PLAIN = "abcd";
|
private final String SHORT_PLAIN = "abcd";
|
||||||
|
|
||||||
|
/** Good base64 string */
|
||||||
|
private final String GOOD_BASE64 =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
/** Bad base64 string */
|
||||||
|
private final String BAD_BASE64 = "CgpTZW50IGZyb20gU2Ftc3VuZyB0YWJsZXQ=";
|
||||||
|
|
||||||
|
/** Encoding type */
|
||||||
|
private final String BASE64 = "base64";
|
||||||
|
|
||||||
/** long subject which will be split into two MIME/Base64 chunks */
|
/** long subject which will be split into two MIME/Base64 chunks */
|
||||||
private final String LONG_UNICODE_SPLIT =
|
private final String LONG_UNICODE_SPLIT =
|
||||||
@ -501,7 +515,20 @@ public class MimeUtilityTest extends TestCase {
|
|||||||
assertTrue(MimeUtility.mimeTypeMatches("match/this", arrayTwo));
|
assertTrue(MimeUtility.mimeTypeMatches("match/this", arrayTwo));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: tests for decodeBody(InputStream in, String contentTransferEncoding)
|
// TODO: tests for decodeBody(InputStream in, String contentTransferEncoding)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm that decodeBody() does not crash when
|
||||||
|
* given bad Base64 data.
|
||||||
|
*/
|
||||||
|
public void testDecodeBody_BadBase64() throws IOException {
|
||||||
|
InputStream in = new ByteArrayInputStream(GOOD_BASE64.getBytes("us-ascii"));
|
||||||
|
assertNotNull(MimeUtility.decodeBody(in, BASE64));
|
||||||
|
|
||||||
|
in = new ByteArrayInputStream(BAD_BASE64.getBytes("us-ascii"));
|
||||||
|
assertNotNull(MimeUtility.decodeBody(in, BASE64));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: tests for collectParts(Part part, ArrayList<Part> viewables, ArrayList<Part> attachments)
|
// TODO: tests for collectParts(Part part, ArrayList<Part> viewables, ArrayList<Part> attachments)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user