mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-07-01 11:48:38 -04:00
Work around missing blank line after last header
Detect when a newline doesn't follow the last header when parsing SGML and break out of the header-parsing loop early. Add an example .qfx file demonstrating the broken behavior we're working around and a test.
This commit is contained in:
10
response.go
10
response.go
@ -35,6 +35,16 @@ type Response struct {
|
||||
func (or *Response) readSGMLHeaders(r *bufio.Reader) error {
|
||||
var seenHeader, seenVersion bool = false, false
|
||||
for {
|
||||
// Some financial institutions do not properly leave an empty line after the last header.
|
||||
// Avoid attempting to read another header in that case.
|
||||
next, err := r.Peek(1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if next[0] == '<' {
|
||||
break
|
||||
}
|
||||
|
||||
line, err := r.ReadString('\n')
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user