Don't use dependency injection for HtmlSanitizer

This commit is contained in:
cketti 2022-01-26 03:11:35 +01:00
parent 013e0dc788
commit 7c05ec5b21
4 changed files with 6 additions and 9 deletions

View file

@ -2,10 +2,9 @@ package com.fsck.k9.message.html
import org.jsoup.nodes.Document
class HtmlProcessor internal constructor(
private val htmlSanitizer: HtmlSanitizer,
private val displayHtml: DisplayHtml
) {
class HtmlProcessor internal constructor(private val displayHtml: DisplayHtml) {
private val htmlSanitizer = HtmlSanitizer()
fun processForDisplay(html: String?): String {
return htmlSanitizer.sanitize(html)
.addCustomHeadContents()

View file

@ -1,11 +1,10 @@
package com.fsck.k9.message.html
class HtmlProcessorFactory(
private val htmlSanitizer: HtmlSanitizer,
private val displayHtmlFactory: DisplayHtmlFactory
) {
fun create(settings: HtmlSettings): HtmlProcessor {
val displayHtml = displayHtmlFactory.create(settings)
return HtmlProcessor(htmlSanitizer, displayHtml)
return HtmlProcessor(displayHtml)
}
}

View file

@ -3,7 +3,7 @@ package com.fsck.k9.message.html
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
class HtmlSanitizer {
internal class HtmlSanitizer {
private val headCleaner = HeadCleaner()
private val bodyCleaner = BodyCleaner()

View file

@ -3,7 +3,6 @@ package com.fsck.k9.message.html
import org.koin.dsl.module
val htmlModule = module {
single { HtmlProcessorFactory(get(), get()) }
single { HtmlSanitizer() }
single { HtmlProcessorFactory(displayHtmlFactory = get()) }
single { DisplayHtmlFactory() }
}