Loading k9mail-library/src/main/java/com/fsck/k9/mail/internet/MessageExtractor.java +4 −2 Original line number Diff line number Diff line Loading @@ -59,6 +59,8 @@ public class MessageExtractor { } else { throw new MessagingException("Provided invalid part: " + part); } } catch (UnsupportedEncodingException e) { Log.e(LOG_TAG, "Unable to getTextFromPart", e); } catch (IOException e) { Log.e(LOG_TAG, "Unable to getTextFromPart", e); } catch (MessagingException e) { Loading @@ -68,7 +70,7 @@ public class MessageExtractor { } private static String getTextFromTextPart(Part part, Body body, String mimeType, long textSizeLimit) throws IOException, MessagingException { throws IOException, MessagingException, UnsupportedEncodingException { /* * We've got a text part, so let's see if it needs to be processed further. */ Loading k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeUtility.java +2 −2 Original line number Diff line number Diff line Loading @@ -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 * merged into {@link Body}. */ public static InputStream decodeBody(Body body) throws MessagingException { public static InputStream decodeBody(Body body) throws MessagingException, UnsupportedEncodingException { InputStream inputStream; if (body instanceof RawDataBody) { RawDataBody rawDataBody = (RawDataBody) body; Loading @@ -1044,7 +1044,7 @@ public class MimeUtility { } }; } else { throw new UnsupportedOperationException("Encoding for RawDataBody not supported: " + encoding); throw new UnsupportedEncodingException(encoding); } } else { inputStream = body.getInputStream(); Loading k9mail-library/src/main/java/com/fsck/k9/mail/internet/UnsupportedEncodingException.java 0 → 100644 +7 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.internet; public class UnsupportedEncodingException extends Exception { public UnsupportedEncodingException(String encoding) { super("Unsupported encoding: "+encoding); } } k9mail-library/src/test/java/com/fsck/k9/mail/internet/MimeMessageParseTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,23 @@ public class MimeMessageParseTest { ""); } @Test(expected = UnsupportedEncodingException.class) public void testSinglePartUnknownEncoding_throwsUnsupportedEncodingException() throws Exception { MimeMessage msg = parseWithoutRecurse(toStream( "From: <adam@example.org>\r\n" + "To: <eva@example.org>\r\n" + "Subject: Testmail\r\n" + "MIME-Version: 1.0\r\n" + "Content-type: text/plain\r\n" + "Content-Transfer-Encoding: utf-8\r\n" + "\r\n" + "dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n")); checkAddresses(msg.getFrom(), "adam@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org"); streamToString(MimeUtility.decodeBody(msg.getBody())); } @Test public void testMultipartSingleLayerRecurse() throws Exception { MimeMessage msg = parseWithRecurse(toStream( Loading k9mail/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.internet.TextBody; import com.fsck.k9.mail.internet.UnsupportedEncodingException; import com.fsck.k9.message.MessageBuilder.Callback; import com.fsck.k9.view.RecipientSelectView.Recipient; import org.apache.commons.io.IOUtils; Loading Loading @@ -507,7 +508,7 @@ public class PgpMessageBuilderTest { InputStream inputStream = MimeUtility.decodeBody(signatureBodyPart.getBody()); IOUtils.copy(inputStream, bos); Assert.assertEquals(reason, expected, new String(bos.toByteArray())); } catch (IOException | MessagingException e) { } catch (IOException | MessagingException | UnsupportedEncodingException e) { Assert.fail(); } } Loading Loading
k9mail-library/src/main/java/com/fsck/k9/mail/internet/MessageExtractor.java +4 −2 Original line number Diff line number Diff line Loading @@ -59,6 +59,8 @@ public class MessageExtractor { } else { throw new MessagingException("Provided invalid part: " + part); } } catch (UnsupportedEncodingException e) { Log.e(LOG_TAG, "Unable to getTextFromPart", e); } catch (IOException e) { Log.e(LOG_TAG, "Unable to getTextFromPart", e); } catch (MessagingException e) { Loading @@ -68,7 +70,7 @@ public class MessageExtractor { } private static String getTextFromTextPart(Part part, Body body, String mimeType, long textSizeLimit) throws IOException, MessagingException { throws IOException, MessagingException, UnsupportedEncodingException { /* * We've got a text part, so let's see if it needs to be processed further. */ Loading
k9mail-library/src/main/java/com/fsck/k9/mail/internet/MimeUtility.java +2 −2 Original line number Diff line number Diff line Loading @@ -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 * merged into {@link Body}. */ public static InputStream decodeBody(Body body) throws MessagingException { public static InputStream decodeBody(Body body) throws MessagingException, UnsupportedEncodingException { InputStream inputStream; if (body instanceof RawDataBody) { RawDataBody rawDataBody = (RawDataBody) body; Loading @@ -1044,7 +1044,7 @@ public class MimeUtility { } }; } else { throw new UnsupportedOperationException("Encoding for RawDataBody not supported: " + encoding); throw new UnsupportedEncodingException(encoding); } } else { inputStream = body.getInputStream(); Loading
k9mail-library/src/main/java/com/fsck/k9/mail/internet/UnsupportedEncodingException.java 0 → 100644 +7 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.internet; public class UnsupportedEncodingException extends Exception { public UnsupportedEncodingException(String encoding) { super("Unsupported encoding: "+encoding); } }
k9mail-library/src/test/java/com/fsck/k9/mail/internet/MimeMessageParseTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,23 @@ public class MimeMessageParseTest { ""); } @Test(expected = UnsupportedEncodingException.class) public void testSinglePartUnknownEncoding_throwsUnsupportedEncodingException() throws Exception { MimeMessage msg = parseWithoutRecurse(toStream( "From: <adam@example.org>\r\n" + "To: <eva@example.org>\r\n" + "Subject: Testmail\r\n" + "MIME-Version: 1.0\r\n" + "Content-type: text/plain\r\n" + "Content-Transfer-Encoding: utf-8\r\n" + "\r\n" + "dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n")); checkAddresses(msg.getFrom(), "adam@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org"); streamToString(MimeUtility.decodeBody(msg.getBody())); } @Test public void testMultipartSingleLayerRecurse() throws Exception { MimeMessage msg = parseWithRecurse(toStream( Loading
k9mail/src/test/java/com/fsck/k9/message/PgpMessageBuilderTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.internet.TextBody; import com.fsck.k9.mail.internet.UnsupportedEncodingException; import com.fsck.k9.message.MessageBuilder.Callback; import com.fsck.k9.view.RecipientSelectView.Recipient; import org.apache.commons.io.IOUtils; Loading Loading @@ -507,7 +508,7 @@ public class PgpMessageBuilderTest { InputStream inputStream = MimeUtility.decodeBody(signatureBodyPart.getBody()); IOUtils.copy(inputStream, bos); Assert.assertEquals(reason, expected, new String(bos.toByteArray())); } catch (IOException | MessagingException e) { } catch (IOException | MessagingException | UnsupportedEncodingException e) { Assert.fail(); } } Loading