ofxparse icon indicating copy to clipboard operation
ofxparse copied to clipboard

OfxPreprocessedFile() crashes on an empty close tag like this: <MEMO/>

Open toddInPortland opened this issue 2 years ago • 0 comments

tokens that look like <MEMO/> cause OfxPreprocessedFile() to set is_closing_tag=false and is_open_tag=true which, in turn causes re.findall() to fault. This flavor of token appears in the ofx file from my credit union, onpointcu.com. It may be encoded wrong, but the right fix would be a better parse code that does not allow the code to fault.

The fix is to add change OfxPreprocessedFile() so that is_closing_tag accounts for this. I can push the patch, but I would need permission to push.

--- a/ofxparse/ofxparse.py
+++ b/ofxparse/ofxparse.py
@@ -169,7 +169,7 @@ class OfxPreprocessedFile(OfxFile):
         tokens = re.split(r'(?i)(</?[a-z0-9_\.]+>)', ofx_string)
         new_fh = StringIO()
         for token in tokens:
-            is_closing_tag = token.startswith('</')
+            is_closing_tag = token.startswith('</') or token.endswith('/>')
             is_processing_tag = token.startswith('<?')
             is_cdata = token.startswith('<!')
             is_tag = token.startswith('<') and not is_cdata

toddInPortland avatar Apr 24 '22 19:04 toddInPortland