csingley / ofxtools

Python OFX Library
Other
301 stars 68 forks source link

OFX header is malformed #119

Closed paulmalherbe closed 3 years ago

paulmalherbe commented 3 years ago

Traceback (most recent call last): File "/home/paul/test.py", line 4, in parser.parse("test.ofx") File "/home/paul/.pyenv/versions/3.9.1/lib/python3.9/site-packages/ofxtools/Parser.py", line 85, in parse self.header, message = self._read(source) File "/home/paul/.pyenv/versions/3.9.1/lib/python3.9/site-packages/ofxtools/Parser.py", line 118, in _read header, message = parse_header(source) File "/home/paul/.pyenv/versions/3.9.1/lib/python3.9/site-packages/ofxtools/header.py", line 294, in parse_header header, header_end_index = OFXHeaderV1.parse(rawheader) File "/home/paul/.pyenv/versions/3.9.1/lib/python3.9/site-packages/ofxtools/header.py", line 81, in parse raise OFXHeaderError(f"OFX header is malformed:\n{rawheader}") ofxtools.header.OFXHeaderError: OFX header is malformed: <?xml version='1.0' encoding='utf-8' standalone='no'?>

<?OFX OFXHEADER="200" VERSION="200" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>

0 INFO
csingley commented 3 years ago

Without anything else to go on, I have to agree, that's severely malformed. It doesn't appear to be an OFX file at all.

paulmalherbe commented 3 years ago

How do I attach a copy of the ofx file as .ofx is not a supported file type?

csingley commented 3 years ago

You can try changing the file extension, or pasting the text here protected by code formatting indicators.

paulmalherbe commented 3 years ago
The first line of the file contains:
<?xml version='1.0' encoding='utf-8' standalone='no'?>
If I replace the single inverted commas with double inverted
  commas it passes.
<?xml version="1.0" encoding="utf-8" standalone="no"?>

On 2021/02/09 15:43, Christopher
  Singley wrote:

  You can try changing the file extension, or pasting the text
    here protected by code formatting indicators.
  —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub, or unsubscribe.
  [

{ "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/csingley/ofxtools/issues/119#issuecomment-775945382", "url": "https://github.com/csingley/ofxtools/issues/119#issuecomment-775945382", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

csingley commented 3 years ago

OK, I understand now.

The XML spec allows either single or double quotes in the XML declaration, but my code only allows double quotes.

Thank you for the bug report; this should not be difficult to fix.

csingley commented 3 years ago

Pushed a fix in b887c7d. Let me know if that works for you.