Closed
Description
Dallas Hopewell opened SPR-13847 and commented
I have a web application that is throwing the following exception after updating from Spring Framework version 4.1.7 to 4.2.4
Caused by java.lang.StringIndexOutOfBoundsException: String index out of range: -3
java.lang.String.substring(String.java:1967)
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter$ResourceUrlEncodingResponseWrapper.encodeURL(ResourceUrlEncodingFilter.java:80)
javax.servlet.http.HttpServletResponseWrapper.encodeURL(HttpServletResponseWrapper.java:76)
javax.servlet.http.HttpServletResponseWrapper.encodeURL(HttpServletResponseWrapper.java:76)
org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper.encodeURL(SaveContextOnUpdateOrErrorResponseWrapper.java:118)
javax.servlet.http.HttpServletResponseWrapper.encodeURL(HttpServletResponseWrapper.java:76)
org.apache.taglibs.standard.tag.common.core.UrlSupport.doEndTag(UrlSupport.java:117)
org.apache.jsp.WEB_002dINF.jsp.tasks.context_jsp._jspx_meth_c_005furl_005f0(context_jsp.java:400)
org.apache.jsp.WEB_002dINF.jsp.tasks.context_jsp._jspService(context_jsp.java:153)
The part of the JSP where the error occurs is: -
<c:url var="reviewUrl" value="review.html"><c:param name="referrer" value="${referrer}"/></c:url>
The problem seems to be when the javax.servlet.http.HttpServletResponseWrapper#encodeURL(String) method is invoked with a 'relative' URL path including a query string, and that query string index in the URL path is less than the number of characters in the web application's context path then the exception is thrown.
Affects: 4.2.4
Attachments:
- SPR13847.java (4.28 kB)
Issue Links:
- ResourceUrlProvider should only consider paths and not request parameters [SPR-13374] #17956 ResourceUrlProvider should only consider paths and not request parameters
- StringIndexOutOfBoundsException in ResourceUrlEncodingFilter [SPR-13018] #17609 StringIndexOutOfBoundsException in ResourceUrlEncodingFilter
- StringIndexOutOfBoundsException when rewriting links in CSS resources [SPR-16526] #21069 StringIndexOutOfBoundsException when rewriting links in CSS resources