File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
main/java/org/springframework/expression/spel/ast
test/java/org/springframework/expression/spel Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public class OperatorMatches extends Operator {
47
47
* Maximum number of characters permitted in a regular expression.
48
48
* @since 5.2.23
49
49
*/
50
- private static final int MAX_REGEX_LENGTH = 256 ;
50
+ private static final int MAX_REGEX_LENGTH = 1024 ;
51
51
52
52
private final ConcurrentMap <String , Pattern > patternCache ;
53
53
Original file line number Diff line number Diff line change @@ -482,18 +482,24 @@ void matchesWithPatternAccessThreshold() {
482
482
483
483
@ Test
484
484
void matchesWithPatternLengthThreshold () {
485
- String pattern = "(0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" +
486
- "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" +
487
- "01234567890123456789012345678901234567890123456789|abc)" ;
488
- assertThat (pattern ).hasSize (256 );
489
- Expression expr = parser .parseExpression ("'abc' matches '" + pattern + "'" );
485
+ String pattern = String .format ("(%s|X)" , repeat ("1234" , 255 ));
486
+ assertThat (pattern ).hasSize (1024 );
487
+ Expression expr = parser .parseExpression ("'X' matches '" + pattern + "'" );
490
488
assertThat (expr .getValue (context , Boolean .class )).isTrue ();
491
489
492
490
pattern += "?" ;
493
- assertThat (pattern ).hasSize (257 );
491
+ assertThat (pattern ).hasSize (1025 );
494
492
evaluateAndCheckError ("'abc' matches '" + pattern + "'" , Boolean .class , SpelMessage .MAX_REGEX_LENGTH_EXCEEDED );
495
493
}
496
494
495
+ private String repeat (String str , int count ) {
496
+ String result = "" ;
497
+ for (int i = 0 ; i < count ; i ++) {
498
+ result += str ;
499
+ }
500
+ return result ;
501
+ }
502
+
497
503
}
498
504
499
505
@ Nested
You can’t perform that action at this time.
0 commit comments