Apply ResourceHandlerUtils to Groovy markup templates

Closes gh-36902
This commit is contained in:
rstoyanchev
2026-06-22 11:57:12 +01:00
parent 1a89363a5c
commit 12f9a5c2a5
@@ -35,6 +35,7 @@ import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.resource.ResourceHandlerUtils;
/**
* An extension of Groovy's {@link groovy.text.markup.TemplateConfiguration} and
@@ -223,7 +224,11 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
@Override
public URL resolveTemplate(String templatePath) throws IOException {
Assert.state(this.classLoader != null, "No template ClassLoader available");
return GroovyMarkupConfigurer.this.resolveTemplate(this.classLoader, templatePath);
String path = ResourceHandlerUtils.normalizeInputPath(templatePath);
if (ResourceHandlerUtils.shouldIgnoreInputPath(path)) {
throw new IOException("Invalid template path:" + templatePath);
}
return GroovyMarkupConfigurer.this.resolveTemplate(this.classLoader, path);
}
}