1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 00:58:50 -05:00

Avoid NullPointerException.

The name parameter in Content-Type may be not set.
This commit is contained in:
Koji Arai 2011-04-28 00:23:16 +09:00
parent 90a5ca8ec2
commit a4f7288d37

View File

@ -1672,20 +1672,22 @@ public class LocalStore extends Store implements Serializable {
body = new LocalAttachmentBody(Uri.parse(contentUri), mApplication);
}
MimeBodyPart bp = new LocalAttachmentBodyPart(body, id);
bp.setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64");
if (name != null) {
String encoded_name = EncoderUtil.encodeIfNecessary(name,
EncoderUtil.Usage.WORD_ENTITY, 7);
MimeBodyPart bp = new LocalAttachmentBodyPart(body, id);
bp.setHeader(MimeHeader.HEADER_CONTENT_TYPE,
String.format("%s;\n name=\"%s\"",
type,
encoded_name));
bp.setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, "base64");
bp.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION,
String.format("%s;\n filename=\"%s\";\n size=%d",
contentDisposition,
encoded_name, // TODO: Should use encoded word defined in RFC 2231.
size));
}
bp.setHeader(MimeHeader.HEADER_CONTENT_ID, contentId);
/*