File tree 2 files changed +13
-7
lines changed
main/java/org/springframework/expression/spel/ast
test/java/org/springframework/expression/spel
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 = 1000 ;
51
51
52
52
private final ConcurrentMap <String , Pattern > patternCache ;
53
53
Original file line number Diff line number Diff line change @@ -201,18 +201,24 @@ void matchesWithPatternAccessThreshold() {
201
201
202
202
@ Test
203
203
void matchesWithPatternLengthThreshold () {
204
- String pattern = "(0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" +
205
- "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" +
206
- "01234567890123456789012345678901234567890123456789|abc)" ;
207
- assertThat (pattern ).hasSize (256 );
208
- Expression expr = parser .parseExpression ("'abc' matches '" + pattern + "'" );
204
+ String pattern = String .format ("^(%s|X)" , repeat ("12345" , 199 ));
205
+ assertThat (pattern ).hasSize (1000 );
206
+ Expression expr = parser .parseExpression ("'X' matches '" + pattern + "'" );
209
207
assertThat (expr .getValue (context , Boolean .class )).isTrue ();
210
208
211
209
pattern += "?" ;
212
- assertThat (pattern ).hasSize (257 );
210
+ assertThat (pattern ).hasSize (1001 );
213
211
evaluateAndCheckError ("'abc' matches '" + pattern + "'" , Boolean .class , SpelMessage .MAX_REGEX_LENGTH_EXCEEDED );
214
212
}
215
213
214
+ private String repeat (String str , int count ) {
215
+ String result = "" ;
216
+ for (int i = 0 ; i < count ; i ++) {
217
+ result += str ;
218
+ }
219
+ return result ;
220
+ }
221
+
216
222
// mixing operators
217
223
@ Test
218
224
public void testMixingOperators01 () {
You can’t perform that action at this time.
0 commit comments