From 12f9a5c2a51bbae7b3cfb1e9f2385fa7ba6fe671 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Mon, 22 Jun 2026 11:57:12 +0100 Subject: [PATCH] Apply ResourceHandlerUtils to Groovy markup templates Closes gh-36902 --- .../web/servlet/view/groovy/GroovyMarkupConfigurer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java index 8d62b7264c7..df3932e05d6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java @@ -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); } }