unfold+decode header value in getContentType() and getDisposition()
This commit is contained in:
parent
1c8a6f05d0
commit
4d3bc41c0a
7 changed files with 16 additions and 21 deletions
|
@ -18,7 +18,7 @@ public interface Part {
|
|||
|
||||
String getContentType();
|
||||
|
||||
String getDisposition() throws MessagingException;
|
||||
String getDisposition();
|
||||
|
||||
String getContentId();
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class DecoderUtil {
|
|||
|
||||
// ANDROID: Most strings will not include "=?" so a quick test can prevent unneeded
|
||||
// object creation. This could also be handled via lazy creation of the StringBuilder.
|
||||
if (body.indexOf("=?") == -1) {
|
||||
if (!body.contains("=?")) {
|
||||
return body;
|
||||
}
|
||||
|
||||
|
|
|
@ -440,12 +440,10 @@ public class MessageExtractor {
|
|||
}
|
||||
|
||||
private static String getContentDisposition(Part part) {
|
||||
try {
|
||||
String disposition = part.getDisposition();
|
||||
if (disposition != null) {
|
||||
return MimeUtility.getHeaderParameter(disposition, null);
|
||||
}
|
||||
} catch (MessagingException e) { /* ignore */ }
|
||||
String disposition = part.getDisposition();
|
||||
if (disposition != null) {
|
||||
return MimeUtility.getHeaderParameter(disposition, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,11 +92,11 @@ public class MimeBodyPart extends BodyPart {
|
|||
@Override
|
||||
public String getContentType() {
|
||||
String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE);
|
||||
return (contentType == null) ? "text/plain" : contentType;
|
||||
return (contentType == null) ? "text/plain" : MimeUtility.unfoldAndDecode(contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisposition() throws MessagingException {
|
||||
public String getDisposition() {
|
||||
return getFirstHeader(MimeHeader.HEADER_CONTENT_DISPOSITION);
|
||||
}
|
||||
|
||||
|
|
|
@ -164,12 +164,12 @@ public class MimeMessage extends Message {
|
|||
@Override
|
||||
public String getContentType() {
|
||||
String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE);
|
||||
return (contentType == null) ? "text/plain" : contentType;
|
||||
return (contentType == null) ? "text/plain" : MimeUtility.unfoldAndDecode(contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisposition() throws MessagingException {
|
||||
return getFirstHeader(MimeHeader.HEADER_CONTENT_DISPOSITION);
|
||||
public String getDisposition() {
|
||||
return MimeUtility.unfoldAndDecode(getFirstHeader(MimeHeader.HEADER_CONTENT_DISPOSITION));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -280,7 +280,7 @@ public class AttachmentPresenter {
|
|||
return ret;
|
||||
}
|
||||
|
||||
String contentType = MimeUtility.unfoldAndDecode(part.getContentType());
|
||||
String contentType = part.getContentType();
|
||||
String name = MimeUtility.getHeaderParameter(contentType, "name");
|
||||
if (name != null) {
|
||||
if (part instanceof LocalBodyPart) {
|
||||
|
|
|
@ -280,14 +280,11 @@ public class MessageViewInfoExtractor {
|
|||
* @return The (file)name of the part if available. An empty string, otherwise.
|
||||
*/
|
||||
private static String getPartName(Part part) {
|
||||
try {
|
||||
String disposition = part.getDisposition();
|
||||
if (disposition != null) {
|
||||
String name = getHeaderParameter(disposition, "filename");
|
||||
return (name == null) ? "" : name;
|
||||
}
|
||||
String disposition = part.getDisposition();
|
||||
if (disposition != null) {
|
||||
String name = getHeaderParameter(disposition, "filename");
|
||||
return (name == null) ? "" : name;
|
||||
}
|
||||
catch (MessagingException e) { /* ignore */ }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue