Merge branch '5.1.x'
This commit is contained in:
commit
cfc4a59135
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -172,7 +172,9 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||||
|
|
||||||
private String getExtension(String coding) {
|
private String getExtension(String coding) {
|
||||||
String extension = this.extensions.get(coding);
|
String extension = this.extensions.get(coding);
|
||||||
Assert.state(extension != null, () -> "No file extension associated with content coding " + coding);
|
if (extension == null) {
|
||||||
|
throw new IllegalStateException("No file extension associated with content coding " + coding);
|
||||||
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -167,7 +167,9 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||||
|
|
||||||
private String getExtension(String coding) {
|
private String getExtension(String coding) {
|
||||||
String extension = this.extensions.get(coding);
|
String extension = this.extensions.get(coding);
|
||||||
Assert.state(extension != null, () -> "No file extension associated with content coding " + coding);
|
if (extension == null) {
|
||||||
|
throw new IllegalStateException("No file extension associated with content coding " + coding);
|
||||||
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.web.filter.GenericFilterBean;
|
import org.springframework.web.filter.GenericFilterBean;
|
||||||
import org.springframework.web.util.UrlPathHelper;
|
import org.springframework.web.util.UrlPathHelper;
|
||||||
|
|
||||||
|
|
@ -87,7 +86,6 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||||
initLookupPath((ResourceUrlProvider) value);
|
initLookupPath((ResourceUrlProvider) value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initLookupPath(ResourceUrlProvider urlProvider) {
|
private void initLookupPath(ResourceUrlProvider urlProvider) {
|
||||||
|
|
@ -97,10 +95,12 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||||
String requestUri = pathHelper.getRequestUri(this);
|
String requestUri = pathHelper.getRequestUri(this);
|
||||||
String lookupPath = pathHelper.getLookupPathForRequest(this);
|
String lookupPath = pathHelper.getLookupPathForRequest(this);
|
||||||
this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
|
this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
|
||||||
Assert.isTrue(this.indexLookupPath != -1, () ->
|
if (this.indexLookupPath == -1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
"Failed to find lookupPath '" + lookupPath + "' within requestUri '" + requestUri + "'. " +
|
"Failed to find lookupPath '" + lookupPath + "' within requestUri '" + requestUri + "'. " +
|
||||||
"Does the path have invalid encoded characters " +
|
"Does the path have invalid encoded characters for characterEncoding '" +
|
||||||
"for characterEncoding=" + getRequest().getCharacterEncoding() + "?");
|
getRequest().getCharacterEncoding() + "'?");
|
||||||
|
}
|
||||||
this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);
|
this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);
|
||||||
if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
|
if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
|
||||||
String contextPath = pathHelper.getContextPath(this);
|
String contextPath = pathHelper.getContextPath(this);
|
||||||
|
|
@ -116,7 +116,7 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||||
public String resolveUrlPath(String url) {
|
public String resolveUrlPath(String url) {
|
||||||
if (this.resourceUrlProvider == null) {
|
if (this.resourceUrlProvider == null) {
|
||||||
logger.trace("ResourceUrlProvider not available via request attribute " +
|
logger.trace("ResourceUrlProvider not available via request attribute " +
|
||||||
"ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR");
|
ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (this.indexLookupPath != null && url.startsWith(this.prefixLookupPath)) {
|
if (this.indexLookupPath != null && url.startsWith(this.prefixLookupPath)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue