0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-20 12:12:15 +02:00

Merge pull request #6588 from thundernest/keep_base_element

Keep `<base>` element
This commit is contained in:
cketti 2023-01-19 12:13:24 +01:00 committed by GitHub
commit 14c5c07e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import org.jsoup.parser.Tag
import org.jsoup.select.NodeTraversor
import org.jsoup.select.NodeVisitor
private val ALLOWED_TAGS = listOf("style", "meta")
private val ALLOWED_TAGS = listOf("style", "meta", "base")
internal class HeadCleaner {
fun clean(dirtyDocument: Document, cleanedDocument: Document) {

View File

@ -465,6 +465,25 @@ class HtmlSanitizerTest {
assertTagsNotStripped("var")
}
@Test
fun `should keep 'base' element`() {
val html =
"""
<html>
<head>
<base href="https://domain.example/">
</head>
<body>
<a href="relative">Link</a>
</body>
</html>
""".compactHtml()
val result = htmlSanitizer.sanitize(html)
assertThat(result.toCompactString()).isEqualTo(html)
}
private fun assertTagsNotStripped(element: String) {
val html = """<$element>some text</$element>"""
@ -491,4 +510,6 @@ class HtmlSanitizerTest {
}
private fun String.trimLineBreaks() = replace("\n", "")
private fun String.compactHtml() = lines().joinToString(separator = "") { it.trim() }
}