ofx4j icon indicating copy to clipboard operation
ofx4j copied to clipboard

Ampersand in OFX v1 file not supported

Open nicoepp opened this issue 3 years ago • 1 comments

An OFX v1 file downloaded from CIBC contained a line similar to the following

<MEMO>DEBIT MEMO 05987 EFT CREDIT PAYMENT REVERSAL ABM CHANNEL & CARD MANAGEMT SE

resulting in the following stacktrace:

Exception in thread "main" java.lang.IllegalStateException: java.io.IOException: Unexpected EOF
	at com.webcohesion.ofx4j.io.AggregateUnmarshaller.unmarshal(AggregateUnmarshaller.java:70)
	at com.plantango.ofx.App.main(App.java:38)
Caused by: java.io.IOException: Unexpected EOF
	at net.n3.nanoxml.StdXMLReader.read(Unknown Source)
	at net.n3.nanoxml.XMLUtil.read(Unknown Source)
	at net.n3.nanoxml.ContentReader.read(Unknown Source)
	at net.n3.nanoxml.ContentReaderBackdoor.read(ContentReaderBackdoor.java:24)
	at java.base/java.io.Reader.read(Reader.java:229)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.readCharacters(NanoXMLOFXReader.java:200)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:173)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:150)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:150)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:150)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:150)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:150)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.processOFXTag(NanoXMLOFXReader.java:150)
	at com.webcohesion.ofx4j.io.nanoxml.NanoXMLOFXReader.parseV1FromFirstElement(NanoXMLOFXReader.java:52)
	at com.webcohesion.ofx4j.io.BaseOFXReader.parse(BaseOFXReader.java:113)
	at com.webcohesion.ofx4j.io.AggregateUnmarshaller.unmarshal(AggregateUnmarshaller.java:63)
	... 1 more

Note the unescaped & in the memo. I tried parsing and converting with the Python library ofxtools which worked without issues. The OFX v1 spec itself doesn't seem to require escaping special symbols like & AFAIK.

Escaping ampersand by replacing the & with &amp; fixed the issue for me. I don't know if we wan't to fix this in the library (or just recommend preprocessing the file) but a better error message would definitively be helpful

nicoepp avatar Oct 19 '21 19:10 nicoepp

What is the forecast for this correction?

Luiz-Otavio-Dorigon avatar Mar 08 '24 19:03 Luiz-Otavio-Dorigon