From 14cd0f3e42e13927f9852d2cb74cc0098c1a429c Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 7 Jul 2023 14:21:15 +0200 Subject: Do not leak unknown asset paths into HTML (#3061) Fixes #3040 --- .../renderers/html/innerTemplating/DefaultTemplateModelFactory.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt index 4fee280e..aae2f65d 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt @@ -92,7 +92,7 @@ class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFact private fun Appendable.resourcesForPage(pathToRoot: String, resources: List): Unit = resources.forEach { - append(with(createHTML()) { + val resourceHtml = with(createHTML()) { when { it.URIExtension == "css" -> link( @@ -112,7 +112,11 @@ class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFact it.isImage() -> link(href = if (it.isAbsolute) it else "$pathToRoot$it") else -> null } - } ?: it) + } + + if (resourceHtml != null) { + append(resourceHtml) + } } } -- cgit