|
17 | 17 | package org.springframework.web.servlet;
|
18 | 18 |
|
19 | 19 | import java.io.IOException;
|
20 |
| - |
21 | 20 | import javax.servlet.RequestDispatcher;
|
22 | 21 | import javax.servlet.ServletException;
|
23 | 22 | import javax.servlet.http.HttpServletRequest;
|
@@ -271,18 +270,18 @@ private void doInclude(HttpServletRequest request, HttpServletResponse response,
|
271 | 270 | if (this.contentType != null) {
|
272 | 271 | response.setContentType(this.contentType);
|
273 | 272 | }
|
274 |
| - String[] resourceUrls = |
275 |
| - StringUtils.tokenizeToStringArray(resourceUrl, RESOURCE_URL_DELIMITERS); |
276 |
| - for (int i = 0; i < resourceUrls.length; i++) { |
| 273 | + String[] resourceUrls = StringUtils.tokenizeToStringArray(resourceUrl, RESOURCE_URL_DELIMITERS); |
| 274 | + for (String url : resourceUrls) { |
| 275 | + String path = StringUtils.cleanPath(url); |
277 | 276 | // check whether URL matches allowed resources
|
278 |
| - if (this.allowedResources != null && !this.pathMatcher.match(this.allowedResources, resourceUrls[i])) { |
279 |
| - throw new ServletException("Resource [" + resourceUrls[i] + |
| 277 | + if (this.allowedResources != null && !this.pathMatcher.match(this.allowedResources, path)) { |
| 278 | + throw new ServletException("Resource [" + path + |
280 | 279 | "] does not match allowed pattern [" + this.allowedResources + "]");
|
281 | 280 | }
|
282 | 281 | if (logger.isDebugEnabled()) {
|
283 |
| - logger.debug("Including resource [" + resourceUrls[i] + "]"); |
| 282 | + logger.debug("Including resource [" + path + "]"); |
284 | 283 | }
|
285 |
| - RequestDispatcher rd = request.getRequestDispatcher(resourceUrls[i]); |
| 284 | + RequestDispatcher rd = request.getRequestDispatcher(path); |
286 | 285 | rd.include(request, response);
|
287 | 286 | }
|
288 | 287 | }
|
|
0 commit comments