mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-10-30 05:20:05 -04: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(): {},
|
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]
|
setTypes, ok := responseTypes[start.Name.Local]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Invalid message set: " + start.Name.Local)
|
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 {
|
if err := d.DecodeElement(responseMessage, &startElement); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if ok, err := responseMessage.Valid(version); !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
*msgs = append(*msgs, responseMessage)
|
*msgs = append(*msgs, responseMessage)
|
||||||
} else {
|
} else {
|
||||||
return errors.New("Didn't find an opening element")
|
return errors.New("Didn't find an opening element")
|
||||||
@ -348,7 +351,7 @@ func ParseResponse(reader io.Reader) (*Response, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("Invalid message set: " + start.Name.Local)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user