Skip to content

SPR-14293: StringIndexOutOfBoundsException #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,9 @@ private PropertyTokenHolder getPropertyNameTokens(String propertyName) {
}
String key = propertyName.substring(keyStart + PROPERTY_KEY_PREFIX.length(), keyEnd);
if ((key.startsWith("'") && key.endsWith("'")) || (key.startsWith("\"") && key.endsWith("\""))) {
key = key.substring(1, key.length() - 1);
if (key.length() > 1) {
key = key.substring(1, key.length() - 1);
}
}
keys.add(key);
searchIndex = keyEnd + PROPERTY_KEY_SUFFIX.length();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,22 @@ public void getPropertyWithOptionalAndAutoGrow() {
assertEquals("x", accessor.getPropertyValue("object.name"));
}

@Test
public void checkNotWritablePropertyIsInvalidCharacter() {
TestBean target = new TestBean();
try {
BeanWrapper accessor = createAccessor(target);
accessor.setPropertyValue("[']", "foobar");
fail("Should throw exception on invalid property");
}
catch (NotWritablePropertyException ex) {
assertNull(ex.getPossibleMatches());
}
catch (RuntimeException re) {
fail("Should not throw runtime exception on invalid property");
}
}


@SuppressWarnings("unused")
private interface AliasedProperty {
Expand Down