Remove unnecessary escapes in regular expressions
See gh-24470
This commit is contained in:
parent
cf9a052e3a
commit
273812f9c5
|
@ -147,7 +147,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||||
/**
|
/**
|
||||||
* The {@code Pattern} used to match placeholders.
|
* The {@code Pattern} used to match placeholders.
|
||||||
*/
|
*/
|
||||||
private static final Pattern PATTERN = Pattern.compile("\\$\\[\\p{Alpha}+\\]");
|
private static final Pattern PATTERN = Pattern.compile("\\$\\[\\p{Alpha}+]");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code Set} of allowed placeholders.
|
* The {@code Set} of allowed placeholders.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2020 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.
|
||||||
|
@ -77,7 +77,7 @@ public class AntPathMatcher implements PathMatcher {
|
||||||
|
|
||||||
private static final int CACHE_TURNOFF_THRESHOLD = 65536;
|
private static final int CACHE_TURNOFF_THRESHOLD = 65536;
|
||||||
|
|
||||||
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}");
|
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?}");
|
||||||
|
|
||||||
private static final char[] WILDCARD_CHARS = { '*', '?', '{' };
|
private static final char[] WILDCARD_CHARS = { '*', '?', '{' };
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ public class AntPathMatcher implements PathMatcher {
|
||||||
*/
|
*/
|
||||||
protected static class AntPathStringMatcher {
|
protected static class AntPathStringMatcher {
|
||||||
|
|
||||||
private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?\\}|[^/{}]|\\\\[{}])+?)\\}");
|
private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}");
|
||||||
|
|
||||||
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
|
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ClassPathResourceTests {
|
||||||
*/
|
*/
|
||||||
private static final String FQ_RESOURCE_PATH_WITH_LEADING_SLASH = '/' + FQ_RESOURCE_PATH;
|
private static final String FQ_RESOURCE_PATH_WITH_LEADING_SLASH = '/' + FQ_RESOURCE_PATH;
|
||||||
|
|
||||||
private static final Pattern DESCRIPTION_PATTERN = Pattern.compile("^class path resource \\[(.+?)\\]$");
|
private static final Pattern DESCRIPTION_PATTERN = Pattern.compile("^class path resource \\[(.+?)]$");
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -47,7 +47,7 @@ public abstract class TestContextResourceUtils {
|
||||||
|
|
||||||
private static final String SLASH = "/";
|
private static final String SLASH = "/";
|
||||||
|
|
||||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile(".*\\$\\{[^\\}]+\\}.*");
|
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile(".*\\$\\{[^}]+}.*");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.springframework.util.MultiValueMap;
|
||||||
public abstract class UriComponents implements Serializable {
|
public abstract class UriComponents implements Serializable {
|
||||||
|
|
||||||
/** Captures URI template variable names. */
|
/** Captures URI template variable names. */
|
||||||
private static final Pattern NAMES_PATTERN = Pattern.compile("\\{([^/]+?)\\}");
|
private static final Pattern NAMES_PATTERN = Pattern.compile("\\{([^/]+?)}");
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -76,11 +76,11 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
|
|
||||||
private static final String HOST_IPV4_PATTERN = "[^\\[/?#:]*";
|
private static final String HOST_IPV4_PATTERN = "[^\\[/?#:]*";
|
||||||
|
|
||||||
private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}\\:\\.]*[%\\p{Alnum}]*\\]";
|
private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]";
|
||||||
|
|
||||||
private static final String HOST_PATTERN = "(" + HOST_IPV6_PATTERN + "|" + HOST_IPV4_PATTERN + ")";
|
private static final String HOST_PATTERN = "(" + HOST_IPV6_PATTERN + "|" + HOST_IPV4_PATTERN + ")";
|
||||||
|
|
||||||
private static final String PORT_PATTERN = "(\\d*(?:\\{[^/]+?\\})?)";
|
private static final String PORT_PATTERN = "(\\d*(?:\\{[^/]+?})?)";
|
||||||
|
|
||||||
private static final String PATH_PATTERN = "([^?#]*)";
|
private static final String PATH_PATTERN = "([^?#]*)";
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||||
*/
|
*/
|
||||||
class RegexPathElement extends PathElement {
|
class RegexPathElement extends PathElement {
|
||||||
|
|
||||||
private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?\\}|[^/{}]|\\\\[{}])+?)\\}");
|
private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}");
|
||||||
|
|
||||||
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
|
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ import org.springframework.web.util.UriUtils;
|
||||||
*/
|
*/
|
||||||
public class RedirectView extends AbstractUrlBasedView {
|
public class RedirectView extends AbstractUrlBasedView {
|
||||||
|
|
||||||
private static final Pattern URI_TEMPLATE_VARIABLE_PATTERN = Pattern.compile("\\{([^/]+?)\\}");
|
private static final Pattern URI_TEMPLATE_VARIABLE_PATTERN = Pattern.compile("\\{([^/]+?)}");
|
||||||
|
|
||||||
|
|
||||||
private HttpStatus statusCode = HttpStatus.SEE_OTHER;
|
private HttpStatus statusCode = HttpStatus.SEE_OTHER;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransp
|
||||||
/**
|
/**
|
||||||
* Pattern for validating callback parameter values.
|
* Pattern for validating callback parameter values.
|
||||||
*/
|
*/
|
||||||
private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_\\.]*");
|
private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_.]*");
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -303,16 +303,16 @@ public class MessageBrokerBeanDefinitionParserTests {
|
||||||
WebSocketMessageBrokerStats stats = this.appContext.getBean(name, WebSocketMessageBrokerStats.class);
|
WebSocketMessageBrokerStats stats = this.appContext.getBean(name, WebSocketMessageBrokerStats.class);
|
||||||
String actual = stats.toString();
|
String actual = stats.toString();
|
||||||
String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " +
|
String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " +
|
||||||
"0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " +
|
"0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)], " +
|
||||||
"stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " +
|
"stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)], " +
|
||||||
"stompBrokerRelay\\[0 sessions, relayhost:1234 \\(not available\\), " +
|
"stompBrokerRelay\\[0 sessions, relayhost:1234 \\(not available\\), " +
|
||||||
"processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " +
|
"processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)], " +
|
||||||
"inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " +
|
"inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " +
|
||||||
"completed tasks = \\d\\], " +
|
"completed tasks = \\d], " +
|
||||||
"outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " +
|
"outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " +
|
||||||
"completed tasks = \\d\\], " +
|
"completed tasks = \\d], " +
|
||||||
"sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " +
|
"sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, " +
|
||||||
"completed tasks = \\d\\]";
|
"completed tasks = \\d]";
|
||||||
|
|
||||||
assertThat(actual.matches(expected)).as("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual).isTrue();
|
assertThat(actual.matches(expected)).as("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual).isTrue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,12 +168,12 @@ public class WebSocketMessageBrokerConfigurationSupportTests {
|
||||||
WebSocketMessageBrokerStats stats = config.getBean(name, WebSocketMessageBrokerStats.class);
|
WebSocketMessageBrokerStats stats = config.getBean(name, WebSocketMessageBrokerStats.class);
|
||||||
String actual = stats.toString();
|
String actual = stats.toString();
|
||||||
String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " +
|
String expected = "WebSocketSession\\[0 current WS\\(0\\)-HttpStream\\(0\\)-HttpPoll\\(0\\), " +
|
||||||
"0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)\\], " +
|
"0 total, 0 closed abnormally \\(0 connect failure, 0 send limit, 0 transport error\\)], " +
|
||||||
"stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)\\], " +
|
"stompSubProtocol\\[processed CONNECT\\(0\\)-CONNECTED\\(0\\)-DISCONNECT\\(0\\)], " +
|
||||||
"stompBrokerRelay\\[null\\], " +
|
"stompBrokerRelay\\[null], " +
|
||||||
"inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " +
|
"inboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d], " +
|
||||||
"outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\], " +
|
"outboundChannel\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d], " +
|
||||||
"sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d\\]";
|
"sockJsScheduler\\[pool size = \\d, active threads = \\d, queued tasks = \\d, completed tasks = \\d]";
|
||||||
|
|
||||||
assertThat(actual.matches(expected)).as("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual).isTrue();
|
assertThat(actual.matches(expected)).as("\nExpected: " + expected.replace("\\", "") + "\n Actual: " + actual).isTrue();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue