Efficient checks for empty strings and single character matches
Closes gh-25552 Closes gh-25553
This commit is contained in:
@@ -31,6 +31,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.HandlerExecutionChain;
|
||||
|
||||
/**
|
||||
@@ -127,7 +128,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
|
||||
// We need to care for the default handler directly, since we need to
|
||||
// expose the PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE for it as well.
|
||||
Object rawHandler = null;
|
||||
if ("/".equals(lookupPath)) {
|
||||
if (StringUtils.matchesCharacter(lookupPath, '/')) {
|
||||
rawHandler = getRootHandler();
|
||||
}
|
||||
if (rawHandler == null) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
@@ -100,7 +101,7 @@ public class ResourceUrlEncodingFilter extends GenericFilterBean {
|
||||
throw new LookupPathIndexException(lookupPath, requestUri);
|
||||
}
|
||||
this.prefixLookupPath = requestUri.substring(0, this.indexLookupPath);
|
||||
if ("/".equals(lookupPath) && !"/".equals(requestUri)) {
|
||||
if (StringUtils.matchesCharacter(lookupPath, '/') && !StringUtils.matchesCharacter(requestUri, '/')) {
|
||||
String contextPath = pathHelper.getContextPath(this);
|
||||
if (requestUri.equals(contextPath)) {
|
||||
this.indexLookupPath = requestUri.length();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -260,7 +260,7 @@ public class ErrorsTag extends AbstractHtmlElementBodyTag implements BodyTag {
|
||||
@Override
|
||||
protected String autogenerateId() throws JspException {
|
||||
String path = getPropertyPath();
|
||||
if ("".equals(path) || "*".equals(path)) {
|
||||
if (!StringUtils.hasLength(path) || "*".equals(path)) {
|
||||
path = (String) this.pageContext.getAttribute(
|
||||
FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user