diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
index d6e77add5..ef974180c 100644
--- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
+++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpMsg.kt
@@ -176,7 +176,6 @@ object PgpMsg {
"span" to arrayOf("color"),
"div" to arrayOf("color"),
"p" to arrayOf("color"),
- "em" to arrayOf("style"), // Typescript: tests rely on this, could potentially remove
"td" to arrayOf("width", "height"),
"hr" to arrayOf("color", "height"),
)
diff --git a/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpMsgHtmlSanitizerTest.kt b/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpMsgHtmlSanitizerTest.kt
new file mode 100644
index 000000000..a2085e751
--- /dev/null
+++ b/FlowCrypt/src/test/java/com/flowcrypt/email/security/pgp/PgpMsgHtmlSanitizerTest.kt
@@ -0,0 +1,61 @@
+/*
+ * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
+ */
+
+package com.flowcrypt.email.security.pgp
+
+import org.jsoup.Jsoup
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class PgpMsgHtmlSanitizerTest {
+ @Test
+ fun testStripsArbitraryCssFromEmStyle() {
+ val result = sanitize(
+ "FAKE SECURITY ALERT"
+ )
+
+ assertTrue(result.select("[style]").isEmpty())
+ assertEquals("FAKE SECURITY ALERT", result.select("em").text())
+ }
+
+ @Test
+ fun testStripsEmStyleWithObfuscatedCssAndAttributeCase() {
+ val variants = listOf(
+ "overlay",
+ "overlay",
+ "overlay",
+ "overlay"
+ )
+
+ for (variant in variants) {
+ val result = sanitize(variant)
+ assertTrue("variant: $variant", result.select("[style]").isEmpty())
+ assertEquals("variant: $variant", "overlay", result.select("em").text())
+ }
+ }
+
+ @Test
+ fun testStripsEmStyleWhenRemoteContentIsBlocked() {
+ val result = sanitize(
+ "
" +
+ "overlay"
+ )
+
+ assertTrue(result.select("[style]").isEmpty())
+ assertEquals("overlay", result.select("em").text())
+ }
+
+ @Test
+ fun testKeepsPlainEmphasis() {
+ val result = sanitize("important")
+
+ assertTrue(result.select("[style]").isEmpty())
+ assertEquals("important", result.select("em").text())
+ }
+
+ private fun sanitize(dirtyHtml: String) =
+ Jsoup.parse(requireNotNull(PgpMsg.sanitizeHtmlKeepBasicTags(dirtyHtml)))
+}