Correctly parse property name in path "map[key[foo]]"
This commit is contained in:
committed by
Juergen Hoeller
parent
7b11c3b599
commit
6899624155
@@ -933,7 +933,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex);
|
||||
searchIndex = -1;
|
||||
if (keyStart != -1) {
|
||||
int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length());
|
||||
int keyEnd = getPropertyNameKeyEnd(propertyName, keyStart + PROPERTY_KEY_PREFIX.length());
|
||||
if (keyEnd != -1) {
|
||||
if (actualName == null) {
|
||||
actualName = propertyName.substring(0, keyStart);
|
||||
@@ -958,6 +958,29 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
return tokens;
|
||||
}
|
||||
|
||||
private static int getPropertyNameKeyEnd(String propertyName, int startIndex) {
|
||||
int unclosedPrefixes = 0;
|
||||
int length = propertyName.length();
|
||||
for (int i = startIndex; i < length; i++) {
|
||||
switch (propertyName.charAt(i)) {
|
||||
case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
|
||||
// The property name contains opening prefix(es)
|
||||
unclosedPrefixes++;
|
||||
break;
|
||||
case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
|
||||
if (unclosedPrefixes == 0) {
|
||||
// No unclosed prefix(es) in the property name (left), this is the suffix we are looking for
|
||||
return i;
|
||||
} else {
|
||||
// This suffix does not close the initial prefix, but one that occurred within the property name
|
||||
unclosedPrefixes--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(getClass().getName());
|
||||
|
||||
Reference in New Issue
Block a user