mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Ensure that whitespaces don't break bean invocation in SpEL
Fixes: #7343
This commit is contained in:
@@ -72,7 +72,9 @@ class BeanMethodInvocationGenerator {
|
||||
int parametersEndIndex = expression.indexOf(')');
|
||||
String[] beanMethodArgumentExpressions = {};
|
||||
if (parametersEndIndex > parametersStartIndex + 1) {
|
||||
beanMethodArgumentExpressions = expression.substring(parametersStartIndex + 1, parametersEndIndex).split(",");
|
||||
beanMethodArgumentExpressions = expression.substring(parametersStartIndex + 1, parametersEndIndex).trim()
|
||||
.split("\\s*,\\s*");
|
||||
;
|
||||
}
|
||||
/*
|
||||
* We need to make sure the cache key contains the both the expression and the parameter types of the method
|
||||
|
||||
@@ -85,6 +85,15 @@ public class BeanMethodCheckTest {
|
||||
assertSuccess(() -> beanWithBeanMethodChecks.withParams("geo", new Person("geo")), "withParams", USER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithParamsAndConstant() {
|
||||
assertSuccess(() -> beanWithBeanMethodChecks.withParamAndConstant(new Person("geo")), "withParamAndConstant",
|
||||
ANONYMOUS);
|
||||
assertFailureFor(() -> beanWithBeanMethodChecks.withParamAndConstant(new Person("other")), ForbiddenException.class,
|
||||
USER);
|
||||
assertSuccess(() -> beanWithBeanMethodChecks.withParamAndConstant(new Person("geo")), "withParamAndConstant", USER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithExtraUnusedParam() {
|
||||
assertFailureFor(() -> someInterface.doSomething("other", 1, new Person("geo")), UnauthorizedException.class,
|
||||
|
||||
@@ -21,6 +21,11 @@ public class BeanWithBeanMethodChecks {
|
||||
return "withParams";
|
||||
}
|
||||
|
||||
@PreAuthorize("@personChecker.check(#person, 'geo')")
|
||||
public String withParamAndConstant(Person person) {
|
||||
return "withParamAndConstant";
|
||||
}
|
||||
|
||||
@PreAuthorize("@personChecker.check(#person, #input)")
|
||||
public String anotherWithParams(String input, Person person) {
|
||||
return "anotherWithParams";
|
||||
|
||||
Reference in New Issue
Block a user