{"action":"created","issue":{"url":"https://api.github.com/repos/csingley/ofxtools/issues/38","repository_url":"https://api.github.com/repos/csingley/ofxtools","labels_url":"https://api.github.com/repos/csingley/ofxtools/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/csingley/ofxtools/issues/38/comments","events_url":"https://api.github.com/repos/csingley/ofxtools/issues/38/events","html_url":"https://github.com/csingley/ofxtools/issues/38","id":332937097,"node_id":"MDU6SXNzdWUzMzI5MzcwOTc=","number":38,"title":"OFX Ver 1.x.x does not format SGML correctly","user":{"login":"fergbrain","id":1291387,"node_id":"MDQ6VXNlcjEyOTEzODc=","avatar_url":"https://avatars3.githubusercontent.com/u/1291387?v=4","gravatar_id":"","url":"https://api.github.com/users/fergbrain","html_url":"https://github.com/fergbrain","followers_url":"https://api.github.com/users/fergbrain/followers","following_url":"https://api.github.com/users/fergbrain/following{/other_user}","gists_url":"https://api.github.com/users/fergbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/fergbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fergbrain/subscriptions","organizations_url":"https://api.github.com/users/fergbrain/orgs","repos_url":"https://api.github.com/users/fergbrain/repos","events_url":"https://api.github.com/users/fergbrain/events{/privacy}","received_events_url":"https://api.github.com/users/fergbrain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-15T23:09:34Z","updated_at":"2018-06-16T00:42:45Z","closed_at":null,"author_association":"NONE","body":"As far as I can tell (based on testing and the spec at http://www.ofx.net/downloads.html) tags that don't have additional nested tags have no end tag. For example downloading an OFX profile _should_ generate the following:\r\n\r\n```\r\nOFXHEADER:100\r\nDATA:OFXSGML\r\nVERSION:102\r\nSECURITY:NONE\r\nENCODING:USASCII\r\nCHARSET:NONE\r\nCOMPRESSION:NONE\r\nOLDFILEUID:NONE\r\nNEWFILEUID:4c8980e0-9664-40a9-9de1-2fa763615089\r\n\r\n<OFX>\r\n    <SIGNONMSGSRQV1>\r\n        <SONRQ>\r\n            <DTCLIENT>20180615225707\r\n            <USERID>anonymous00000000000000000000000\r\n            <USERPASS>anonymous00000000000000000000000\r\n            <LANGUAGE>ENG\r\n            <FI>\r\n                <ORG>BECU\r\n                <FID>3670\r\n            </FI>\r\n            <APPID>QWIN\r\n            <APPVER>2300\r\n        </SONRQ>\r\n    </SIGNONMSGSRQV1>\r\n    <PROFMSGSRQV1>\r\n        <PROFTRNRQ>\r\n        <TRNUID>097eefe1-8f81-43a2-8b43-cae62a774802\r\n        <PROFRQ>\r\n            <CLIENTROUTING>NONE\r\n            <DTPROFUP>19900101000000\r\n        </PROFRQ>\r\n        </PROFTRNRQ>\r\n    </PROFMSGSRQV1>\r\n</OFX>\r\n```\r\n\r\nHowever, it instead generates the following:\r\n```\r\nOFXHEADER:100\r\nDATA:OFXSGML\r\nVERSION:102\r\nSECURITY:NONE\r\nENCODING:USASCII\r\nCHARSET:NONE\r\nCOMPRESSION:NONE\r\nOLDFILEUID:NONE\r\nNEWFILEUID:4c8980e0-9664-40a9-9de1-2fa763615089\r\n\r\n<OFX>\r\n    <SIGNONMSGSRQV1>\r\n        <SONRQ>\r\n            <DTCLIENT>20180615225707</DTCLIENT>\r\n            <USERID>anonymous00000000000000000000000</USERID>\r\n            <USERPASS>anonymous00000000000000000000000</USERPASS>\r\n            <LANGUAGE>ENG</LANGUAGE>\r\n            <FI>\r\n                <ORG>BECU</ORG>\r\n                <FID>3670</FID>\r\n            </FI>\r\n            <APPID>QWIN</APPID>\r\n            <APPVER>2300</APPVER>\r\n        </SONRQ>\r\n    </SIGNONMSGSRQV1>\r\n    <PROFMSGSRQV1>\r\n        <PROFTRNRQ>\r\n            <TRNUID>097eefe1-8f81-43a2-8b43-cae62a774802</TRNUID>\r\n            <PROFRQ>\r\n                <CLIENTROUTING>NONE</CLIENTROUTING>\r\n                <DTPROFUP>19900101000000</DTPROFUP>\r\n            </PROFRQ>\r\n        </PROFTRNRQ>\r\n    </PROFMSGSRQV1>\r\n</OFX>\r\n```\r\n\r\nYou can generate this using the following command: `ofxget -n https://onlinebanking.becu.org/ofx/ofxprocessor.asp --fid 3670 --org BECU --appver 2400 -p --version 102`"},"comment":{"url":"https://api.github.com/repos/csingley/ofxtools/issues/comments/397773704","html_url":"https://github.com/csingley/ofxtools/issues/38#issuecomment-397773704","issue_url":"https://api.github.com/repos/csingley/ofxtools/issues/38","id":397773704,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Nzc3MzcwNA==","user":{"login":"fergbrain","id":1291387,"node_id":"MDQ6VXNlcjEyOTEzODc=","avatar_url":"https://avatars3.githubusercontent.com/u/1291387?v=4","gravatar_id":"","url":"https://api.github.com/users/fergbrain","html_url":"https://github.com/fergbrain","followers_url":"https://api.github.com/users/fergbrain/followers","following_url":"https://api.github.com/users/fergbrain/following{/other_user}","gists_url":"https://api.github.com/users/fergbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/fergbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fergbrain/subscriptions","organizations_url":"https://api.github.com/users/fergbrain/orgs","repos_url":"https://api.github.com/users/fergbrain/repos","events_url":"https://api.github.com/users/fergbrain/events{/privacy}","received_events_url":"https://api.github.com/users/fergbrain/received_events","type":"User","site_admin":false},"created_at":"2018-06-16T00:42:45Z","updated_at":"2018-06-16T00:42:45Z","author_association":"NONE","body":"> God, are you forced to used OFXv102?\r\n\r\nAs far as I can tell, yes I am. Fun times.\r\n\r\n>Have you got a reference backing up your assertion?\r\n\r\nThe two things that caught my eye in the spec is section 1.2.2 (\"Request and Response Model\") and section 2.5.1.1 (\"Signon Request <SONRQ>\") from Open Financial Exchange Specification 1.0.2. I've uploaded the section 2.5.1.1 to make it easier for your reference but you can also get it at http://www.ofx.net/downloads.html:\r\n\r\n![2 5 1 1](https://user-images.githubusercontent.com/1291387/41493918-7f487176-7104-11e8-8d1b-50d59816b62d.png)\r\n\r\nIf you note, DTCLIENT, USERID, USERPASS, LANGUAGE, APPID, and APPVER all do _not_ have closing tags noted, whereas SONRQ and FI do. This matches the behavior seen.\r\n\r\nSection 1.2.2 also says,\r\n> The key rule of Open Financial Exchange syntax is that each tag is either an element or an aggregate. Data follows its element tag. An aggregate tag begins a compound tag sequence, which must end with a matching tag; for example, <AGGREGATE> ... </AGGREGATE>. \r\n\r\nThe term \"aggregate\" matches the description used in section 2.5.1.1 and requires the ending tag. I will also admit that I've not been able to find a place in the spec that explicitly says that element tags must _not_ end with a matching tag.\r\n\r\nIt's entirely possible that BECU hasn't correctly implemented the spec, however I started by using mitmproxy with Banktivity to see how they were (successfully) connecting and they don't use end tags...which is how I figured out the issue (I made the same initial assumption you did)\r\n\r\n![mitmproxy_screenshot](https://user-images.githubusercontent.com/1291387/41494068-5646039a-7106-11e8-8767-5cec5af3ec85.png)\r\n\r\nI also used mitmproxy to inspect how ofxtools was actually communicating with BECU and to try to get it to match how Banktivity did it, which is when I ran into the end tags issue described above.\r\n\r\nI think the easiest way to verify this is by running the following:\r\n\r\ncurl -v -X POST --data-binary @ofx.txt --header \"Content-Type: application/x-ofx\" --header \"Accept:*/*, application/x-ofx\" https://onlinebanking.becu.org/ofx/ofxprocessor.asp\r\n\r\nSwap out _bad and _good for...bad and good results. The _only_ difference is the ending tags:\r\n\r\n[ofx_bad.txt](https://github.com/csingley/ofxtools/files/2107745/ofx_bad.txt)\r\n[ofx_good.txt](https://github.com/csingley/ofxtools/files/2107746/ofx_good.txt)"}}
{"actor":{"display_login":"fergbrain"}}