Skip to content

Commit db9b139

Browse files
sbrannenbclozel
authored andcommitted
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
1 parent bd029b9 commit db9b139

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class OperatorMatches extends Operator {
4747
* Maximum number of characters permitted in a regular expression.
4848
* @since 5.2.23
4949
*/
50-
private static final int MAX_REGEX_LENGTH = 1024;
50+
private static final int MAX_REGEX_LENGTH = 1000;
5151

5252
private final ConcurrentMap<String, Pattern> patternCache;
5353

spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,13 @@ void matchesWithPatternAccessThreshold() {
484484

485485
@Test
486486
void matchesWithPatternLengthThreshold() {
487-
String pattern = "(%s|X)".formatted("1234".repeat(255));
488-
assertThat(pattern).hasSize(1024);
487+
String pattern = "^(%s|X)".formatted("12345".repeat(199));
488+
assertThat(pattern).hasSize(1000);
489489
Expression expr = parser.parseExpression("'X' matches '" + pattern + "'");
490490
assertThat(expr.getValue(context, Boolean.class)).isTrue();
491491

492492
pattern += "?";
493-
assertThat(pattern).hasSize(1025);
493+
assertThat(pattern).hasSize(1001);
494494
evaluateAndCheckError("'abc' matches '" + pattern + "'", Boolean.class, SpelMessage.MAX_REGEX_LENGTH_EXCEEDED);
495495
}
496496

0 commit comments

Comments
 (0)