Simplify based on feedback
This commit is contained in:
parent
3e6625dd24
commit
1497b5f781
6 changed files with 10 additions and 11 deletions
|
@ -59,8 +59,6 @@ public class MessageExtractor {
|
||||||
} else {
|
} else {
|
||||||
throw new MessagingException("Provided invalid part: " + part);
|
throw new MessagingException("Provided invalid part: " + part);
|
||||||
}
|
}
|
||||||
} catch (UnsupportedContentTransferEncodingException e) {
|
|
||||||
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
|
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException e) {
|
||||||
|
@ -70,7 +68,7 @@ public class MessageExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTextFromTextPart(Part part, Body body, String mimeType, long textSizeLimit)
|
private static String getTextFromTextPart(Part part, Body body, String mimeType, long textSizeLimit)
|
||||||
throws IOException, MessagingException, UnsupportedContentTransferEncodingException {
|
throws IOException, MessagingException {
|
||||||
/*
|
/*
|
||||||
* We've got a text part, so let's see if it needs to be processed further.
|
* We've got a text part, so let's see if it needs to be processed further.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ public class MimeUtility {
|
||||||
* The ultimate goal is to get to a point where all classes retain the original data and {@code RawDataBody} can be
|
* The ultimate goal is to get to a point where all classes retain the original data and {@code RawDataBody} can be
|
||||||
* merged into {@link Body}.
|
* merged into {@link Body}.
|
||||||
*/
|
*/
|
||||||
public static InputStream decodeBody(Body body) throws MessagingException, UnsupportedContentTransferEncodingException {
|
public static InputStream decodeBody(Body body) throws MessagingException {
|
||||||
InputStream inputStream;
|
InputStream inputStream;
|
||||||
if (body instanceof RawDataBody) {
|
if (body instanceof RawDataBody) {
|
||||||
RawDataBody rawDataBody = (RawDataBody) body;
|
RawDataBody rawDataBody = (RawDataBody) body;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.fsck.k9.mail.internet;
|
package com.fsck.k9.mail.internet;
|
||||||
|
|
||||||
public class UnsupportedContentTransferEncodingException extends Exception {
|
import com.fsck.k9.mail.MessagingException;
|
||||||
|
|
||||||
|
public class UnsupportedContentTransferEncodingException extends MessagingException {
|
||||||
public UnsupportedContentTransferEncodingException(String encoding) {
|
public UnsupportedContentTransferEncodingException(String encoding) {
|
||||||
super("Unsupported encoding: "+encoding);
|
super("Unsupported encoding: "+encoding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,9 @@ public class MessageExtractorTest {
|
||||||
BinaryMemoryBody body = new BinaryMemoryBody("Sample text body".getBytes(), "unknown encoding");
|
BinaryMemoryBody body = new BinaryMemoryBody("Sample text body".getBytes(), "unknown encoding");
|
||||||
part.setBody(body);
|
part.setBody(body);
|
||||||
|
|
||||||
assertNull(MessageExtractor.getTextFromPart(part));
|
String result = MessageExtractor.getTextFromPart(part);
|
||||||
|
|
||||||
|
assertNull(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -140,9 +140,7 @@ public class MimeMessageParseTest {
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
"dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n"));
|
"dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n"));
|
||||||
|
|
||||||
checkAddresses(msg.getFrom(), "adam@example.org");
|
MimeUtility.decodeBody(msg.getBody());
|
||||||
checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org");
|
|
||||||
streamToString(MimeUtility.decodeBody(msg.getBody()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,7 +32,6 @@ import com.fsck.k9.mail.internet.MimeMessage;
|
||||||
import com.fsck.k9.mail.internet.MimeMultipart;
|
import com.fsck.k9.mail.internet.MimeMultipart;
|
||||||
import com.fsck.k9.mail.internet.MimeUtility;
|
import com.fsck.k9.mail.internet.MimeUtility;
|
||||||
import com.fsck.k9.mail.internet.TextBody;
|
import com.fsck.k9.mail.internet.TextBody;
|
||||||
import com.fsck.k9.mail.internet.UnsupportedContentTransferEncodingException;
|
|
||||||
import com.fsck.k9.message.MessageBuilder.Callback;
|
import com.fsck.k9.message.MessageBuilder.Callback;
|
||||||
import com.fsck.k9.view.RecipientSelectView.Recipient;
|
import com.fsck.k9.view.RecipientSelectView.Recipient;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
@ -508,7 +507,7 @@ public class PgpMessageBuilderTest {
|
||||||
InputStream inputStream = MimeUtility.decodeBody(signatureBodyPart.getBody());
|
InputStream inputStream = MimeUtility.decodeBody(signatureBodyPart.getBody());
|
||||||
IOUtils.copy(inputStream, bos);
|
IOUtils.copy(inputStream, bos);
|
||||||
Assert.assertEquals(reason, expected, new String(bos.toByteArray()));
|
Assert.assertEquals(reason, expected, new String(bos.toByteArray()));
|
||||||
} catch (IOException | MessagingException | UnsupportedContentTransferEncodingException e) {
|
} catch (IOException | MessagingException e) {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue