diff --git a/src/backend/xml/sixtp.c b/src/backend/xml/sixtp.c index 31e6d291ad..8e7ef00eb8 100644 --- a/src/backend/xml/sixtp.c +++ b/src/backend/xml/sixtp.c @@ -909,7 +909,8 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding) if (strncmp(cursor, "', &cursor)) { @@ -921,9 +922,12 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding) return GNC_BOOK_NOT_OURS; } - tag_compare = g_strdup_printf("<%s\n", gnc_v2_xml_version_string); + 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 (strncmp(cursor, tag_compare, strlen(tag_compare)) == 0) + if ((strncmp(cursor, tag_compare1, strlen(tag_compare1)) == 0) + || (strncmp(cursor, tag_compare2, strlen(tag_compare2)) == 0)) { if (with_encoding) { @@ -938,13 +942,15 @@ gnc_is_our_first_xml_chunk(char *chunk, gboolean *with_encoding) } } } - g_free (tag_compare); + g_free (tag_compare1); + g_free (tag_compare2); return GNC_BOOK_XML2_FILE; } - g_free (tag_compare); + g_free (tag_compare1); + g_free (tag_compare2); - if (strncmp(cursor, "\n", strlen("\n")) == 0) + if (strncmp(cursor, "", strlen("")) == 0) return GNC_BOOK_XML1_FILE; /* If it doesn't match any of the above but has '