summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJames Lemieux <jplemieux@google.com>2014-05-20 14:18:28 -0700
committerJames Lemieux <jplemieux@google.com>2014-05-21 11:48:39 -0700
commit27a36a6bbeebb6cfd53ad2766463d71ab4b26ce0 (patch)
tree52cf88df25113ff1d4d83e87d383d7316748d8b8 /tests
parentfa75a2de56389ec43306b101dfeba25c5f785901 (diff)
downloadandroid_packages_apps_UnifiedEmail-27a36a6bbeebb6cfd53ad2766463d71ab4b26ce0.tar.gz
android_packages_apps_UnifiedEmail-27a36a6bbeebb6cfd53ad2766463d71ab4b26ce0.tar.bz2
android_packages_apps_UnifiedEmail-27a36a6bbeebb6cfd53ad2766463d71ab4b26ce0.zip
Sanitize HTML bodies from .eml files and support quoted text
b/14567151 Sanitizes HTML email bodies on demand as they are parsed from .eml attachments. Adds the OWASP sanitizer to the license page Adds HTML translation to support quoted text collapsing for emails from Gmail, Yahoo and AOL. Change-Id: Ie710e63054539887f507437e2e4fa6ae8415a305
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/mail/utils/QuotedHtmlSanitizerTest.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/src/com/android/mail/utils/QuotedHtmlSanitizerTest.java b/tests/src/com/android/mail/utils/QuotedHtmlSanitizerTest.java
new file mode 100644
index 000000000..e85fb63cf
--- /dev/null
+++ b/tests/src/com/android/mail/utils/QuotedHtmlSanitizerTest.java
@@ -0,0 +1,48 @@
+package com.android.mail.utils;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+/**
+ * These test cases verify that the HTML email body is transformed correctly to support toggling
+ * the visibility of quoted text.
+ */
+@SmallTest
+public class QuotedHtmlSanitizerTest extends AndroidTestCase {
+ /**
+ * Random garbage in a class attribute of a div is stripped.
+ */
+ public void testGarbageDiv() {
+ // any random class value is disallowed
+ sanitize("<div class=\"garbage\"></div>", "<div></div>");
+ }
+
+ /**
+ * For Gmail, <div class="gmail_quote"> indicates the block of quoted text.
+ */
+ public void testGmailQuotedTextDiv() {
+ sanitize("<div class=\"gmail_quote\"></div>", "<div class=\"elided-text\"></div>");
+ }
+
+ /**
+ * For Yahoo, <div class="yahoo_quoted"> indicates the block of quoted text.
+ */
+ public void testYahooQuotedTextDiv() {
+ sanitize("<div class=\"yahoo_quoted\"></div>", "<div class=\"elided-text\"></div>");
+ }
+
+ /**
+ * For AOL, <div id="AOLMsgPart_RANDOM_GUID"> indicates the block of quoted text.
+ */
+ public void testAOLQuotedTextDiv() {
+ sanitize("<div id=\"AOLMsgPart_1_59da800c-ba5d-45c5-9ff7-29a8264a5bd9\"></div>",
+ "<div class=\"elided-text\"></div>");
+ sanitize("<div id=\"AOLMsgPart_1_b916b4c7-3047-43a9-b24d-83b7ffd2b9b7\"></div>",
+ "<div class=\"elided-text\"></div>");
+ }
+
+ private void sanitize(String dirtyHTML, String expectedHTML) {
+ final String cleansedHTML = HtmlSanitizer.sanitizeHtml(dirtyHTML);
+ assertEquals(expectedHTML, cleansedHTML);
+ }
+}