Kernvirus opened a new issue, #15064:
URL: https://github.com/apache/grails-core/issues/15064

   ### Feature description
   
   Hello,
   
   SimpleDataBinder uses this regex to parse the indexer and it's value from a 
value it wants to map:
   `static final INDEXED_PROPERTY_REGEX = /(.*)\[\s*([^\s]*)\s*\]\s*$/`
   
   But this regex will always choose the last indexer when there are multiple 
present. Example:
   `propName = 'columns[0]['data']'`
   will be matched as
   ```
   indexedPropertyName = 'columns[0]'
   index = 'data'
   ```
   
   I'd argue that this is wrong. A groovy property is not allowed to be named 
`columns[0]` anyways (right?) so matching that makes no sense. It should 
instead consider the first indexer as the indexer that matters. It should be:
   ```
   indexedPropertyName = 'columns'
   index = '0'
   ```
   
   It would be easy to change the regex to pick the first indexer instead like 
so:
   `^(.*?)\[\s*([^\s]*)\s*\]\s*`
   but I'm not sure if that would break anything and if that's enough to 
properly support nested indexers. Is this a feature the SimpleDataBinder should 
support? Since fields that have [] in their name are probably very unlikely to 
exist, making this change may not be that breaking in real usage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to