Merge branch '5.1.x'
This commit is contained in:
@@ -96,10 +96,7 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||
String lookupPath = pathHelper.getLookupPathForRequest(this);
|
||||
this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
|
||||
if (this.indexLookupPath == -1) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to find lookupPath '" + lookupPath + "' within requestUri '" + requestUri + "'. " +
|
||||
"Does the path have invalid encoded characters for characterEncoding '" +
|
||||
getRequest().getCharacterEncoding() + "'?");
|
||||
throw new LookupPathIndexException(lookupPath, requestUri);
|
||||
}
|
||||
this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);
|
||||
if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
|
||||
@@ -164,4 +161,14 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class LookupPathIndexException extends IllegalArgumentException {
|
||||
|
||||
LookupPathIndexException(String lookupPath, String requestUri) {
|
||||
super("Failed to find lookupPath '" + lookupPath + "' within requestUri '" + requestUri + "'. " +
|
||||
"This could be because the path has invalid encoded characters or isn't normalized.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.ServletRequestBindingException;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
/**
|
||||
@@ -48,7 +49,12 @@ public class ResourceUrlProviderExposingInterceptor extends HandlerInterceptorAd
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
|
||||
request.setAttribute(RESOURCE_URL_PROVIDER_ATTR, this.resourceUrlProvider);
|
||||
try {
|
||||
request.setAttribute(RESOURCE_URL_PROVIDER_ATTR, this.resourceUrlProvider);
|
||||
}
|
||||
catch (ResourceUrlEncodingFilter.LookupPathIndexException ex) {
|
||||
throw new ServletRequestBindingException(ex.getMessage(), ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user