PDA

View Full Version : Binding map keys which contain (nested) brackets ([])


cnelson
Aug 31st, 2005, 02:14 PM
I'm binding several values to a map, and from time to time, the map key will contain square brackets. This results in some html that looks like this:


<input type="text" name="entries[Foo Bar (AA), N. A. [cr]]" value="" />



When this is submitted and bound, the key becomes "Foo Bar (AA), N. A. [cr" instead of "Foo Bar (AA), N. A. [cr]", which throws off the whole binding process.

I've found the offending line of code is in BeanWrapperImpl.java (line 610 in version 1.2.4):


int keyEnd = propertyName.indexOf(PROPERTY_KEY_SUFFIX, keyStart + PROPERTY_KEY_PREFIX.length());



This returns the first occurence of ']', not the last.

This seem like a bug to me... anyone have a different opinion on it?

Regards,
Christian

cnelson
Sep 1st, 2005, 07:59 PM
I've created an issue in jira (http://opensource2.atlassian.com/projects/spring/browse/SPR-1274), which also includes a patch that resolves this issue.