use of com.fsck.k9.message.html.HtmlSanitizer in project k-9 by k9mail.
the class MessageViewInfoExtractorTest method setUp.
@Before
public void setUp() throws Exception {
context = RuntimeEnvironment.application;
GlobalsHelper.setContext(context);
HtmlSanitizer dummyHtmlSanitizer = HtmlSanitizerHelper.getDummyHtmlSanitizer();
messageViewInfoExtractor = new MessageViewInfoExtractor(context, null, dummyHtmlSanitizer);
}
use of com.fsck.k9.message.html.HtmlSanitizer in project k-9 by k9mail.
the class MessageViewInfoExtractorTest method testShouldSanitizeOutputHtml.
@Test
public void testShouldSanitizeOutputHtml() throws MessagingException {
// Create text/plain body
TextBody body = new TextBody(BODY_TEXT);
// Create message
MimeMessage message = new MimeMessage();
MimeMessageHelper.setBody(message, body);
message.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain; format=flowed");
// Prepare fixture
HtmlSanitizer htmlSanitizer = mock(HtmlSanitizer.class);
MessageViewInfoExtractor messageViewInfoExtractor = new MessageViewInfoExtractor(context, null, htmlSanitizer);
String value = "--sanitized html--";
when(htmlSanitizer.sanitize(any(String.class))).thenReturn(value);
// Extract text
List<Part> outputNonViewableParts = new ArrayList<>();
ArrayList<Viewable> outputViewableParts = new ArrayList<>();
MessageExtractor.findViewablesAndAttachments(message, outputViewableParts, outputNonViewableParts);
ViewableExtractedText viewableExtractedText = messageViewInfoExtractor.extractTextFromViewables(outputViewableParts);
assertSame(value, viewableExtractedText.html);
}
use of com.fsck.k9.message.html.HtmlSanitizer in project k-9 by k9mail.
the class MessageViewInfoExtractor method getInstance.
public static MessageViewInfoExtractor getInstance() {
Context context = Globals.getContext();
AttachmentInfoExtractor attachmentInfoExtractor = AttachmentInfoExtractor.getInstance();
HtmlSanitizer htmlSanitizer = HtmlSanitizer.getInstance();
return new MessageViewInfoExtractor(context, attachmentInfoExtractor, htmlSanitizer);
}
Aggregations