Change max regex length in SpEL expressions to 1000
This commit changes the max regex length in SpEL expressions from 1024 to 1000 in order to consistently use "round" numbers for recently introduced limits. See gh-30265
This commit is contained in:
parent
bd029b9218
commit
db9b139cf0
|
|
@ -47,7 +47,7 @@ public class OperatorMatches extends Operator {
|
|||
* Maximum number of characters permitted in a regular expression.
|
||||
* @since 5.2.23
|
||||
*/
|
||||
private static final int MAX_REGEX_LENGTH = 1024;
|
||||
private static final int MAX_REGEX_LENGTH = 1000;
|
||||
|
||||
private final ConcurrentMap<String, Pattern> patternCache;
|
||||
|
||||
|
|
|
|||
|
|
@ -484,13 +484,13 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||
|
||||
@Test
|
||||
void matchesWithPatternLengthThreshold() {
|
||||
String pattern = "(%s|X)".formatted("1234".repeat(255));
|
||||
assertThat(pattern).hasSize(1024);
|
||||
String pattern = "^(%s|X)".formatted("12345".repeat(199));
|
||||
assertThat(pattern).hasSize(1000);
|
||||
Expression expr = parser.parseExpression("'X' matches '" + pattern + "'");
|
||||
assertThat(expr.getValue(context, Boolean.class)).isTrue();
|
||||
|
||||
pattern += "?";
|
||||
assertThat(pattern).hasSize(1025);
|
||||
assertThat(pattern).hasSize(1001);
|
||||
evaluateAndCheckError("'abc' matches '" + pattern + "'", Boolean.class, SpelMessage.MAX_REGEX_LENGTH_EXCEEDED);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue