From a4f7288d3749b8ed5c89ee82b59e52bee979b2f2 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Thu, 28 Apr 2011 00:23:16 +0900 Subject: [PATCH] Avoid NullPointerException. The name parameter in Content-Type may be not set. --- src/com/fsck/k9/mail/store/LocalStore.java | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index c0607cd39..55b630d66 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -1672,20 +1672,22 @@ public class LocalStore extends Store implements Serializable { body = new LocalAttachmentBody(Uri.parse(contentUri), mApplication); } - 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)); + if (name != null) { + String encoded_name = EncoderUtil.encodeIfNecessary(name, + EncoderUtil.Usage.WORD_ENTITY, 7); + + bp.setHeader(MimeHeader.HEADER_CONTENT_TYPE, + String.format("%s;\n name=\"%s\"", + type, + encoded_name)); + 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); /*