Skip to content

Commit 90373cc

Browse files
committed
Merge branch '3.1.x' into 3.2.x
2 parents a52f275 + d41cc05 commit 90373cc

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

grails-web-sitemesh/src/main/groovy/org/grails/web/sitemesh/GroovyPageLayoutFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public Decorator getNamedDecorator(HttpServletRequest request, String name, bool
190190

191191
View view;
192192
try {
193-
view = viewResolver.resolveViewName(GrailsResourceUtils.appendPiecesForUri(LAYOUTS_PATH, name),
193+
view = viewResolver.resolveViewName(GrailsResourceUtils.cleanPath(GrailsResourceUtils.appendPiecesForUri(LAYOUTS_PATH, name)),
194194
request.getLocale());
195195
// it's only possible to check that GroovyPageView exists
196196
if (viewMustExist && !(view instanceof AbstractGrailsView)) {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2012 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.grails.web.sitemesh
18+
19+
import org.grails.web.servlet.view.GrailsViewResolver
20+
import org.springframework.mock.web.MockHttpServletRequest
21+
import spock.lang.Issue
22+
import spock.lang.Specification
23+
import spock.lang.Unroll
24+
import javax.servlet.http.HttpServletRequest
25+
26+
/**
27+
* @author Colin Harrington
28+
*/
29+
class GroovyPageLayoutFinderSpec extends Specification {
30+
@Issue("https://github.com/grails/grails-core/issues/10371")
31+
@Unroll("Layout name mapping: #layoutName => #expectedPath")
32+
void "testing layout name resolution"() {
33+
given:
34+
GroovyPageLayoutFinder layoutFinder = new GroovyPageLayoutFinder()
35+
HttpServletRequest request = new MockHttpServletRequest()
36+
layoutFinder.viewResolver = Mock(GrailsViewResolver)
37+
when:
38+
layoutFinder.getNamedDecorator(request, layoutName, false)
39+
40+
then:
41+
1 * layoutFinder.viewResolver.resolveViewName(expectedPath, Locale.ENGLISH)
42+
notThrown(Exception)
43+
44+
where:
45+
layoutName | expectedPath
46+
"foo" | "/layouts/foo"
47+
"foo/bar" | "/layouts/foo/bar"
48+
"../foo" | "/foo"
49+
"../foo/bar" | "/foo/bar"
50+
"../../foo" | "/../foo"
51+
"../foo/../../bar" | "/../bar"
52+
"foo/../../bar" | "/bar"
53+
}
54+
}

0 commit comments

Comments
 (0)