1
0
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:
Martin Kobetic
2019-01-04 11:18:55 -05:00
committed by Aaron Lindsay
parent 7691881132
commit 0f6ceccd86
3 changed files with 71 additions and 2 deletions

View File

@ -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