GNOME Bugzilla – Bug 678214
GnuCash fails to open some post-processed XML files
Last modified: 2018-06-29 23:09:12 UTC
Created attachment 216576 [details] [review] Patch to allow GnuCash to accept modified but valid XML files. I have some Python scripts that load GnuCash XML files, make some modifications, and write them back out. As of GnuCash 2.4.10, GnuCash can no longer load my modified files. Instead, I get the message "This file/URL appears to be from a newer version of GnuCash. You must upgrade your version of GnuCash to work with this data." I did some investigation and found that this is due to r21908, which changed gnc_is_our_first_xml_chunk in src/backend/xml/sixtp.c to check for a linefeed (\n) after the <gnc-v2 tag opening. My files have a space instead, which was causing GnuCash to become confused and think the file was from a later version. I have created a patch to gnc_is_our_first_xml_chunk which instead checks for any whitespace character after the <gnc-v2 tag opening. It applies cleanly to the current trunk and is easily backported to the 2.4 branch (though it can't be applied as is because of whitespace changes on the trunk).
Created attachment 216577 [details] Test file which demonstrates the problem.
Comment on attachment 216576 [details] [review] Patch to allow GnuCash to accept modified but valid XML files. Committed as r22229 (trunk) and r22230 (2.4), thank you very much. Officially I'll add this disclaimer: GnuCash doesn't support any changes to the data file from any tool not using the GnuCash access routines (the "GnuCash Engine"). Given the patch you just sent, you obviously know what you are doing, so feel free to disregard that statement. Your patch was a good improvement to GnuCash in general and hence it was accepted :)
Thanks for taking my patch! I agree with you, and don't expect support or assistance from the GnuCash team for using my own custom tools. In this case, it seemed that this change simplified the GnuCash code as well as made it work better for my case. Glad you agreed :-) Thanks for working to make a great piece of software!
Reassign version to 2.4.x so that individual 2.4 versions can be retired.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=678214. Please update any external references or bookmarks.