Skip to content

Commit ae25eb6

Browse files
GRAILS-11402 - fix data binding problem caused by a request parameter named '_'
1 parent 9240fc3 commit ae25eb6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

grails-databinding/src/main/groovy/org/grails/databinding/SimpleDataBinder.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class SimpleDataBinder implements DataBinder {
241241
def val = source.getPropertyValue key
242242
processIndexedProperty obj, metaProperty, descriptor, val, source, listener, errors
243243
}
244-
} else if (propName.startsWith('_')) { // boolean special handling
244+
} else if (propName.startsWith('_') && propName.length() > 1) { // boolean special handling
245245
def restOfPropertyName = propName[1..-1]
246246
if (!source.containsProperty(restOfPropertyName)) {
247247
metaProperty = obj.metaClass.getMetaProperty restOfPropertyName

grails-test-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/GrailsWebDataBinderSpec.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,19 @@ class GrailsWebDataBinderSpec extends Specification {
12501250
then:
12511251
holder.album.title == 'Some Album'
12521252
}
1253+
1254+
@Issue('GRAILS-11402')
1255+
void 'Test binding when the binding source contains the key "_"'() {
1256+
given:
1257+
def publisher = new Publisher()
1258+
1259+
when:
1260+
binder.bind publisher, [_: '', name: 'Some Publisher'] as SimpleMapDataBindingSource
1261+
1262+
then:
1263+
!publisher.hasErrors()
1264+
publisher.name == 'Some Publisher'
1265+
}
12531266
}
12541267

12551268
@Entity

0 commit comments

Comments
 (0)