Skip to content

Commit

Permalink
Bug #678214 - GnuCash fails to open some post-processed XML files
Browse files Browse the repository at this point in the history
Patch by Daniel Harding
BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22229 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
gjanssens committed Jun 22, 2012
1 parent 1fb8800 commit 867db62
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/backend/xml/sixtp.c
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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)
{
Expand All @@ -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;

Expand Down

0 comments on commit 867db62

Please sign in to comment.