From 6092524d793861b050e56378d88bb90cc6bb72cb Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 3 Oct 2024 11:37:49 +0200 Subject: [PATCH] Fix theme resource loading on Windows, and enable additional test in jdk-integration-tests (#33512) Closes #33508 Signed-off-by: stianst --- .../src/main/java/org/keycloak/theme/ResourceLoader.java | 7 ++++++- .../integration-arquillian/tests/base/testsuites/jdk-suite | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/src/main/java/org/keycloak/theme/ResourceLoader.java b/services/src/main/java/org/keycloak/theme/ResourceLoader.java index 6f667d6890..7bb7e40a6d 100644 --- a/services/src/main/java/org/keycloak/theme/ResourceLoader.java +++ b/services/src/main/java/org/keycloak/theme/ResourceLoader.java @@ -15,7 +15,12 @@ public class ResourceLoader { Path rootPath = Path.of("/", root).normalize().toAbsolutePath(); Path resourcePath = rootPath.resolve(resource).normalize().toAbsolutePath(); if (resourcePath.startsWith(rootPath)) { - URL url = classLoader().getResource(resourcePath.toString().substring(1)); + if (File.separatorChar == '/') { + resource = resourcePath.toString().substring(1); + } else { + resource = resourcePath.toString().substring(2).replace('\\', '/'); + } + URL url = classLoader().getResource(resource); return url != null ? url.openStream() : null; } else { return null; diff --git a/testsuite/integration-arquillian/tests/base/testsuites/jdk-suite b/testsuite/integration-arquillian/tests/base/testsuites/jdk-suite index adc953a127..9b7150e99b 100644 --- a/testsuite/integration-arquillian/tests/base/testsuites/jdk-suite +++ b/testsuite/integration-arquillian/tests/base/testsuites/jdk-suite @@ -15,3 +15,4 @@ SSOTest SamlClientTest TransactionsTest X509BrowserLoginTest +ThemeResourceProviderTest