Prevent subpath injection with disabled setting (#1869)

This commit is contained in:
schroda
2026-01-23 17:30:29 +01:00
committed by GitHub
parent b4595b70d6
commit a58dcc6f19

View File

@@ -204,12 +204,12 @@ object WebInterfaceManager {
val tempWebUIRoot = createServableDirectory() val tempWebUIRoot = createServableDirectory()
val orgIndexHtml = File("$tempWebUIRoot/index.html") val orgIndexHtml = File("$tempWebUIRoot/index.html")
if (orgIndexHtml.exists()) { if (ServerSubpath.isDefined() && orgIndexHtml.exists()) {
val originalIndexHtml = orgIndexHtml.readText() val originalIndexHtml = orgIndexHtml.readText()
val subpathInjectionScript = val subpathInjectionScript =
""" """
<script> <script>
"// <<suwayomi-subpath-injection>>" // <<suwayomi-subpath-injection>>
const baseTag = document.createElement('base'); const baseTag = document.createElement('base');
baseTag.href = location.origin + "${ServerSubpath.asRootPath()}"; baseTag.href = location.origin + "${ServerSubpath.asRootPath()}";
document.head.appendChild(baseTag); document.head.appendChild(baseTag);