Keep 'align' attribute of 'div' elements
This commit is contained in:
parent
9cf73c99d0
commit
27d1dd3828
2 changed files with 19 additions and 0 deletions
|
@ -15,6 +15,7 @@ internal class BodyCleaner {
|
|||
val allowList = Safelist.relaxed()
|
||||
.addTags("font", "hr", "ins", "del", "center", "map", "area", "title")
|
||||
.addAttributes("font", "color", "face", "size")
|
||||
.addAttributes("div", "align")
|
||||
.addAttributes(
|
||||
"table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
|
||||
"width"
|
||||
|
|
|
@ -409,6 +409,24 @@ class HtmlSanitizerTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should keep 'align' attribute on 'div' element`() {
|
||||
val html = """<div align="center">text</div>"""
|
||||
|
||||
val result = htmlSanitizer.sanitize(html)
|
||||
|
||||
assertThat(result.toCompactString()).isEqualTo(
|
||||
"""
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<div align="center">text</div>
|
||||
</body>
|
||||
</html>
|
||||
""".trimIndent().trimLineBreaks()
|
||||
)
|
||||
}
|
||||
|
||||
private fun Document.toCompactString(): String {
|
||||
outputSettings()
|
||||
.prettyPrint(false)
|
||||
|
|
Loading…
Reference in a new issue