mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #678214 - GnuCash fails to open some post-processed XML files
Patch by Daniel Harding BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22229 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1fb8800b44
commit
867db62422
@ -894,6 +894,7 @@ QofBookFileType
|
||||
gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
{
|
||||
char *cursor = NULL;
|
||||
size_t n;
|
||||
|
||||
if (with_encoding)
|
||||
{
|
||||
@ -909,9 +910,6 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
|
||||
if (strncmp(cursor, "<?xml", 5) == 0)
|
||||
{
|
||||
char *tag_compare1;
|
||||
char *tag_compare2;
|
||||
|
||||
if (!search_for('>', &cursor))
|
||||
{
|
||||
return GNC_BOOK_NOT_OURS;
|
||||
@ -922,12 +920,14 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
return GNC_BOOK_NOT_OURS;
|
||||
}
|
||||
|
||||
tag_compare1 = g_strdup_printf("<%s\n", gnc_v2_xml_version_string);
|
||||
/* This second compare is to handle Windows end-of-line markers */
|
||||
tag_compare2 = g_strdup_printf("<%s\r\n", gnc_v2_xml_version_string);
|
||||
if (*cursor != '<')
|
||||
{
|
||||
return GNC_BOOK_NOT_OURS;
|
||||
}
|
||||
|
||||
if ((strncmp(cursor, tag_compare1, strlen(tag_compare1)) == 0)
|
||||
|| (strncmp(cursor, tag_compare2, strlen(tag_compare2)) == 0))
|
||||
n = strlen(gnc_v2_xml_version_string);
|
||||
if ((strncmp(cursor + 1, gnc_v2_xml_version_string, n) == 0)
|
||||
&& isspace(*(cursor + 1 + n)))
|
||||
{
|
||||
if (with_encoding)
|
||||
{
|
||||
@ -942,14 +942,9 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding)
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (tag_compare1);
|
||||
g_free (tag_compare2);
|
||||
return GNC_BOOK_XML2_FILE;
|
||||
}
|
||||
|
||||
g_free (tag_compare1);
|
||||
g_free (tag_compare2);
|
||||
|
||||
if (strncmp(cursor, "<gnc>", strlen("<gnc>")) == 0)
|
||||
return GNC_BOOK_XML1_FILE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user