From 2b8a79e4b74b0ca32c2b6f21147841d22c656dca Mon Sep 17 00:00:00 2001 From: Aaron Ross Date: Sun, 3 Jan 2021 19:07:43 -0800 Subject: [PATCH] review changes --- response.go | 4 ++-- response_test.go | 3 +-- samples/{valid_responses => busted_responses}/wellsfargo.qfx | 0 3 files changed, 3 insertions(+), 4 deletions(-) rename samples/{valid_responses => busted_responses}/wellsfargo.qfx (100%) diff --git a/response.go b/response.go index 7d27665..a510556 100644 --- a/response.go +++ b/response.go @@ -54,7 +54,7 @@ func (or *Response) readSGMLHeaders(r *bufio.Reader) error { // optionally captured & discarded by the trailing `\s*`. Valid SGML headers must // always be present in exactly this order, so a regular expression is acceptable. headerExp := regexp.MustCompile( - `OFXHEADER:\s*(?P\d+)\s*` + + `^OFXHEADER:\s*(?P\d+)\s*` + `DATA:\s*(?P[A-Z]+)\s*` + `VERSION:\s*(?P\d+)\s*` + `SECURITY:\s*(?P[\w]+)\s*` + @@ -62,7 +62,7 @@ func (or *Response) readSGMLHeaders(r *bufio.Reader) error { `CHARSET:\s*(?P[\w-]+)\s*` + `COMPRESSION:\s*(?P[A-Z]+)\s*` + `OLDFILEUID:\s*(?P[\w-]+)\s*` + - `NEWFILEUID:\s*(?P[\w-]+)\s*`) + `NEWFILEUID:\s*(?P[\w-]+)\s*<$`) matches := headerExp.FindStringSubmatch(s) if len(matches) == 0 { diff --git a/response_test.go b/response_test.go index d288607..5655613 100644 --- a/response_test.go +++ b/response_test.go @@ -176,8 +176,7 @@ func TestValidSamples(t *testing.T) { func TestInvalidResponse(t *testing.T) { // in this example, the severity is invalid due to mixed upper and lower case letters - const invalidResponse = ` -OFXHEADER:100 + const invalidResponse = `OFXHEADER:100 DATA:OFXSGML VERSION:102 SECURITY:NONE diff --git a/samples/valid_responses/wellsfargo.qfx b/samples/busted_responses/wellsfargo.qfx similarity index 100% rename from samples/valid_responses/wellsfargo.qfx rename to samples/busted_responses/wellsfargo.qfx