@@ -310,6 +310,7 @@ func parseGroup(mp *msgParser, tags []Tag) {
310310 dm := mp .msg .fields [mp .fieldIndex : mp .fieldIndex + 1 ]
311311 fields := getGroupFields (mp .msg , tags , mp .appDataDictionary )
312312
313+ parseLoop:
313314 for {
314315 mp .fieldIndex ++
315316 mp .parsedFieldBytes = & mp .msg .fields [mp .fieldIndex ]
@@ -350,16 +351,15 @@ func parseGroup(mp *msgParser, tags []Tag) {
350351 fields = getGroupFields (mp .msg , searchTags , mp .appDataDictionary )
351352 continue
352353 }
353- if len (tags ) > 1 {
354- searchTags = tags [:len (tags )- 1 ]
355- }
356- // Did this tag occur after a nested group and belongs to the parent group.
357- if isNumInGroupField (mp .msg , searchTags , mp .appDataDictionary ) {
358- // Add the field member to the group.
359- dm = append (dm , * mp .parsedFieldBytes )
360- // Continue parsing the parent group.
361- fields = getGroupFields (mp .msg , searchTags , mp .appDataDictionary )
362- continue
354+ // The tag isn't a member of the current group. Walk up: if an
355+ // ancestor group includes it, resume there; otherwise it's body-level.
356+ for len (tags ) > 1 {
357+ tags = tags [:len (tags )- 1 ]
358+ fields = getGroupFields (mp .msg , tags , mp .appDataDictionary )
359+ if isGroupMember (mp .parsedFieldBytes .tag , fields ) {
360+ dm = append (dm , * mp .parsedFieldBytes )
361+ continue parseLoop
362+ }
363363 }
364364 // Add the repeating group.
365365 mp .msg .Body .add (dm )
0 commit comments