|
|
@ -107,6 +107,7 @@ import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.activation.DataHandler;
|
|
|
|
import javax.activation.DataHandler;
|
|
|
|
|
|
|
|
import javax.activation.DataSource;
|
|
|
|
import javax.activation.FileDataSource;
|
|
|
|
import javax.activation.FileDataSource;
|
|
|
|
import javax.activation.FileTypeMap;
|
|
|
|
import javax.activation.FileTypeMap;
|
|
|
|
import javax.mail.Address;
|
|
|
|
import javax.mail.Address;
|
|
|
@ -4051,6 +4052,10 @@ public class MessageHelper {
|
|
|
|
|
|
|
|
|
|
|
|
if (part.isMimeType("multipart/mixed")) {
|
|
|
|
if (part.isMimeType("multipart/mixed")) {
|
|
|
|
Object content = part.getContent();
|
|
|
|
Object content = part.getContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof String)
|
|
|
|
|
|
|
|
content = tryParseMultipart((String) content, part.getContentType());
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
Multipart mp = (Multipart) content;
|
|
|
|
Multipart mp = (Multipart) content;
|
|
|
|
for (int i = 0; i < mp.getCount(); i++) {
|
|
|
|
for (int i = 0; i < mp.getCount(); i++) {
|
|
|
@ -4074,6 +4079,10 @@ public class MessageHelper {
|
|
|
|
"application/pkcs7-signature".equals(protocol) ||
|
|
|
|
"application/pkcs7-signature".equals(protocol) ||
|
|
|
|
"application/x-pkcs7-signature".equals(protocol)) {
|
|
|
|
"application/x-pkcs7-signature".equals(protocol)) {
|
|
|
|
Object content = part.getContent();
|
|
|
|
Object content = part.getContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof String)
|
|
|
|
|
|
|
|
content = tryParseMultipart((String) content, part.getContentType());
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
Multipart multipart = (Multipart) content;
|
|
|
|
Multipart multipart = (Multipart) content;
|
|
|
|
if (multipart.getCount() == 2) {
|
|
|
|
if (multipart.getCount() == 2) {
|
|
|
@ -4120,6 +4129,10 @@ public class MessageHelper {
|
|
|
|
String protocol = ct.getParameter("protocol");
|
|
|
|
String protocol = ct.getParameter("protocol");
|
|
|
|
if ("application/pgp-encrypted".equals(protocol) || protocol == null) {
|
|
|
|
if ("application/pgp-encrypted".equals(protocol) || protocol == null) {
|
|
|
|
Object content = part.getContent();
|
|
|
|
Object content = part.getContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof String)
|
|
|
|
|
|
|
|
content = tryParseMultipart((String) content, part.getContentType());
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
Multipart multipart = (Multipart) content;
|
|
|
|
Multipart multipart = (Multipart) content;
|
|
|
|
if (multipart.getCount() == 2) {
|
|
|
|
if (multipart.getCount() == 2) {
|
|
|
@ -4218,6 +4231,10 @@ public class MessageHelper {
|
|
|
|
if (part.isMimeType("multipart/*")) {
|
|
|
|
if (part.isMimeType("multipart/*")) {
|
|
|
|
Multipart multipart;
|
|
|
|
Multipart multipart;
|
|
|
|
Object content = part.getContent(); // Should always be Multipart
|
|
|
|
Object content = part.getContent(); // Should always be Multipart
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof String)
|
|
|
|
|
|
|
|
content = tryParseMultipart((String) content, part.getContentType());
|
|
|
|
|
|
|
|
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
if (content instanceof Multipart) {
|
|
|
|
multipart = (Multipart) part.getContent();
|
|
|
|
multipart = (Multipart) part.getContent();
|
|
|
|
int count = multipart.getCount();
|
|
|
|
int count = multipart.getCount();
|
|
|
@ -4374,6 +4391,35 @@ public class MessageHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Object tryParseMultipart(String text, String contentType) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return new MimeMultipart(new DataSource() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public InputStream getInputStream() throws IOException {
|
|
|
|
|
|
|
|
return new ByteArrayInputStream(text.getBytes(StandardCharsets.ISO_8859_1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public OutputStream getOutputStream() throws IOException {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String getContentType() {
|
|
|
|
|
|
|
|
return contentType;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
|
|
|
|
return "String";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (MessagingException ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ensureEnvelope() throws MessagingException {
|
|
|
|
private void ensureEnvelope() throws MessagingException {
|
|
|
|
_ensureMessage(false, false);
|
|
|
|
_ensureMessage(false, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|