mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-22 03:30:04 -05:00
Check Valid() when parsing responses
This commit is contained in:
parent
2046fa32e5
commit
7f2ca5db0f
@ -219,7 +219,7 @@ var responseTypes = map[string]map[string]reflect.Type{
|
||||
ImageRs.String(): {},
|
||||
}
|
||||
|
||||
func decodeMessageSet(d *xml.Decoder, start xml.StartElement, msgs *[]Message) error {
|
||||
func decodeMessageSet(d *xml.Decoder, start xml.StartElement, msgs *[]Message, version ofxVersion) error {
|
||||
setTypes, ok := responseTypes[start.Name.Local]
|
||||
if !ok {
|
||||
return errors.New("Invalid message set: " + start.Name.Local)
|
||||
@ -245,6 +245,9 @@ func decodeMessageSet(d *xml.Decoder, start xml.StartElement, msgs *[]Message) e
|
||||
if err := d.DecodeElement(responseMessage, &startElement); err != nil {
|
||||
return err
|
||||
}
|
||||
if ok, err := responseMessage.Valid(version); !ok {
|
||||
return err
|
||||
}
|
||||
*msgs = append(*msgs, responseMessage)
|
||||
} else {
|
||||
return errors.New("Didn't find an opening element")
|
||||
@ -348,7 +351,7 @@ func ParseResponse(reader io.Reader) (*Response, error) {
|
||||
if !ok {
|
||||
return nil, errors.New("Invalid message set: " + start.Name.Local)
|
||||
}
|
||||
if err := decodeMessageSet(decoder, start, slice); err != nil {
|
||||
if err := decodeMessageSet(decoder, start, slice, or.Version); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user