Skip to content

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

@toddInPortland

Description

@toddInPortland

tokens that look like 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions