ndless-nspire / Luna

Create TNS files from Lua and XML
Other
57 stars 13 forks source link

Luna mishandles empty tags #29

Open Legimet opened 1 month ago

Legimet commented 1 month ago

The attached TNS file contains XML with an empty tag <sp:ctxt ang="1" cplx="1" comp="1"/>. Running Luna on this XML file produces a malformed TNS. This is because Luna's XML parsing does not detect that this is an empty tag, and thus when it sees the next end tag, it outputs the tag number associated with sp:ctxt.

Based on preliminary testing, it seems that the XML parsing/compression isn't even necessary. Just escaping Unicode seems to be enough. Furthermore, the XML compression doesn't even seem to produce smaller files, which is not that surprising since the XML gets deflated anyway. Maybe I'm missing something here, but it seems to me that we could just get rid of that code.

By the way, it seems that someone else had this issue a year ago: https://old.reddit.com/r/nspire/comments/x3mpy8/unable_to_open_tns_files_created_with_luna/

test.zip

Vogtinator commented 1 month ago

Yeah, so far I've just used explicit close tags everywhere.

Based on preliminary testing, it seems that the XML parsing/compression isn't even necessary. Just escaping Unicode seems to be enough. Furthermore, the XML compression doesn't even seem to produce smaller files, which is not that surprising since the XML gets deflated anyway. Maybe I'm missing something here, but it seems to me that we could just get rid of that code.

I had the exact same thoughts. The XML compression is pretty much useless (arguably worse than useless), so I wonder why it was implemented. Maybe some versions didn't accept unmangled XML or it wasn't known that unmangled XML also works?