Skip to content

Commit 12f9a5c

Browse files
committed
Apply ResourceHandlerUtils to Groovy markup templates
Closes gh-36902
1 parent 1a89363 commit 12f9a5c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.core.io.Resource;
3636
import org.springframework.util.Assert;
3737
import org.springframework.util.StringUtils;
38+
import org.springframework.web.servlet.resource.ResourceHandlerUtils;
3839

3940
/**
4041
* An extension of Groovy's {@link groovy.text.markup.TemplateConfiguration} and
@@ -223,7 +224,11 @@ public void configure(ClassLoader templateClassLoader, TemplateConfiguration con
223224
@Override
224225
public URL resolveTemplate(String templatePath) throws IOException {
225226
Assert.state(this.classLoader != null, "No template ClassLoader available");
226-
return GroovyMarkupConfigurer.this.resolveTemplate(this.classLoader, templatePath);
227+
String path = ResourceHandlerUtils.normalizeInputPath(templatePath);
228+
if (ResourceHandlerUtils.shouldIgnoreInputPath(path)) {
229+
throw new IOException("Invalid template path:" + templatePath);
230+
}
231+
return GroovyMarkupConfigurer.this.resolveTemplate(this.classLoader, path);
227232
}
228233
}
229234

0 commit comments

Comments
 (0)