mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Fix error message for invalid regex in SpEL
Closes gh-36756
This commit is contained in:
+1
-1
@@ -117,7 +117,7 @@ public class OperatorMatches extends Operator {
|
|||||||
|
|
||||||
private void checkRegexLength(String regex) {
|
private void checkRegexLength(String regex) {
|
||||||
if (regex.length() > MAX_REGEX_LENGTH) {
|
if (regex.length() > MAX_REGEX_LENGTH) {
|
||||||
throw new SpelEvaluationException(getStartPosition(),
|
throw new SpelEvaluationException(getRightOperand().getStartPosition(),
|
||||||
SpelMessage.MAX_REGEX_LENGTH_EXCEEDED, MAX_REGEX_LENGTH);
|
SpelMessage.MAX_REGEX_LENGTH_EXCEEDED, MAX_REGEX_LENGTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -534,7 +534,7 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||||||
void matchesWithPatternAccessThreshold() {
|
void matchesWithPatternAccessThreshold() {
|
||||||
String pattern = "^(?=[a-z0-9-]{1,47})([a-z0-9]+[-]{0,1}){1,47}[a-z0-9]{1}$";
|
String pattern = "^(?=[a-z0-9-]{1,47})([a-z0-9]+[-]{0,1}){1,47}[a-z0-9]{1}$";
|
||||||
String expression = "'abcde-fghijklmn-o42pasdfasdfasdf.qrstuvwxyz10x.xx.yyy.zasdfasfd' matches '" + pattern + "'";
|
String expression = "'abcde-fghijklmn-o42pasdfasdfasdf.qrstuvwxyz10x.xx.yyy.zasdfasfd' matches '" + pattern + "'";
|
||||||
evaluateAndCheckError(expression, SpelMessage.FLAWED_PATTERN);
|
evaluateAndCheckError(expression, SpelMessage.FLAWED_PATTERN, 74);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -546,7 +546,7 @@ class EvaluationTests extends AbstractExpressionTests {
|
|||||||
|
|
||||||
pattern += "?";
|
pattern += "?";
|
||||||
assertThat(pattern).hasSize(1001);
|
assertThat(pattern).hasSize(1001);
|
||||||
evaluateAndCheckError("'X' matches '" + pattern + "'", Boolean.class, SpelMessage.MAX_REGEX_LENGTH_EXCEEDED);
|
evaluateAndCheckError("'X' matches '" + pattern + "'", Boolean.class, SpelMessage.MAX_REGEX_LENGTH_EXCEEDED, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user