Skip to content

Commit ac5e2f3

Browse files
committed
Also let <wbr> go through sanitization because why not
If someone is motivated enough to use them, we might as well keep them
1 parent 5fb61b3 commit ac5e2f3

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

HtmlCleaner/src/main/java/com/infomaniak/html/cleaner/BodyCleaner.kt

+17-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,23 @@ internal class BodyCleaner {
3030

3131
init {
3232
val allowList = Safelist.relaxed()
33-
.addTags("area", "button", "center", "del", "font", "hr", "ins", "kbd", "map", "samp", "style", "title", "tt", "var")
33+
.addTags(
34+
"area",
35+
"button",
36+
"center",
37+
"del",
38+
"font",
39+
"hr",
40+
"ins",
41+
"kbd",
42+
"map",
43+
"samp",
44+
"style",
45+
"title",
46+
"tt",
47+
"var",
48+
"wbr",
49+
)
3450
.addAttributes(":all", "class", "dir", "id", "style")
3551
.addAttributes("a", "name")
3652
// Allow all URI schemes in links. Removing all protocols makes the list of protocols empty which means allow all protocols

app/src/main/java/com/infomaniak/mail/utils/HtmlFormatter.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ class HtmlFormatter(private val html: String) {
153153
private const val PRIMARY_COLOR_CODE = "--kmail-primary-color"
154154
private const val KMAIL_MESSAGE_ID = "kmail-message-content"
155155

156-
private val DETECT_BUT_DO_NOT_BREAK = setOf(' ')
157-
private val BREAK_CHARACTERS = setOf(':', '/', '~', '.', ',', '-', '_', '?', '#', '%', '=', '&')
158156
private const val ZERO_WIDTH_SPACE = 0x200B.toChar()
159157
private const val BREAK_LIMIT = 30
160158
// Across a few handpicked representative emails, average text node length for text nodes bigger than 30 characters seems
161159
// to be centered between 60 and 120
162160
private const val OPTIMAL_STRING_LENGTH = 120
161+
private val DETECT_BUT_DO_NOT_BREAK = setOf(' ', ZERO_WIDTH_SPACE) // ZWSP could already be present in the original html
162+
private val BREAK_CHARACTERS = setOf(':', '/', '~', '.', ',', '-', '_', '?', '#', '%', '=', '&')
163163

164164
private fun Context.loadCss(@RawRes cssResId: Int, customColors: List<Pair<String, Int>> = emptyList()): String {
165165
var css = readRawResource(cssResId)

0 commit comments

Comments
 (0)