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 {
4747 * Maximum number of characters permitted in a regular expression.
4848 * @since 5.2.23
4949 */
50- private static final int MAX_REGEX_LENGTH = 256 ;
50+ private static final int MAX_REGEX_LENGTH = 1000 ;
5151
5252 private final ConcurrentMap <String , Pattern > patternCache ;
5353
Original file line number Diff line number Diff line change @@ -201,18 +201,24 @@ void matchesWithPatternAccessThreshold() {
201201
202202 @ Test
203203 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 + "'" );
209207 assertThat (expr .getValue (context , Boolean .class )).isTrue ();
210208
211209 pattern += "?" ;
212- assertThat (pattern ).hasSize (257 );
210+ assertThat (pattern ).hasSize (1001 );
213211 evaluateAndCheckError ("'abc' matches '" + pattern + "'" , Boolean .class , SpelMessage .MAX_REGEX_LENGTH_EXCEEDED );
214212 }
215213
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+
216222 // mixing operators
217223 @ Test
218224 public void testMixingOperators01 () {
You can’t perform that action at this time.
0 commit comments