1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-11-22 11:30:05 -05:00

Handle SGML responses with post-colon spaces in headers

This commit is contained in:
Aaron Lindsay 2017-04-03 20:49:48 -04:00
parent ea133999ee
commit cd39e4f8af

View File

@ -54,30 +54,33 @@ func (or *Response) readSGMLHeaders(r *bufio.Reader) error {
return errors.New("OFX headers malformed") return errors.New("OFX headers malformed")
} }
// Some OFX servers put a space after the colon
headervalue := strings.TrimSpace(header[1])
switch header[0] { switch header[0] {
case "OFXHEADER": case "OFXHEADER":
if header[1] != "100" { if headervalue != "100" {
return errors.New("OFXHEADER is not 100") return errors.New("OFXHEADER is not 100")
} }
seenHeader = true seenHeader = true
case "DATA": case "DATA":
if header[1] != "OFXSGML" { if headervalue != "OFXSGML" {
return errors.New("OFX DATA header does not contain OFXSGML") return errors.New("OFX DATA header does not contain OFXSGML")
} }
case "VERSION": case "VERSION":
switch header[1] { switch headervalue {
case "102", "103", "151", "160": case "102", "103", "151", "160":
seenVersion = true seenVersion = true
or.Version = header[1] or.Version = headervalue
default: default:
return errors.New("Invalid OFX VERSION in header") return errors.New("Invalid OFX VERSION in header")
} }
case "SECURITY": case "SECURITY":
if header[1] != "NONE" { if headervalue != "NONE" {
return errors.New("OFX SECURITY header not NONE") return errors.New("OFX SECURITY header not NONE")
} }
case "COMPRESSION": case "COMPRESSION":
if header[1] != "NONE" { if headervalue != "NONE" {
return errors.New("OFX COMPRESSION header not NONE") return errors.New("OFX COMPRESSION header not NONE")
} }
case "ENCODING", "CHARSET", "OLDFILEUID", "NEWFILEUID": case "ENCODING", "CHARSET", "OLDFILEUID", "NEWFILEUID":