pidgin/pidgin

Restore compatibility with gtkimhtml.c
trac-17280-valid-log-html
2019-10-09, Daniel Kamil Kozar
2e9efd7d3b78
Restore compatibility with gtkimhtml.c

gtkimhtml.c treats the first line of the message specially, and the previously
introduced changes caused problems with displaying conversation logs when saved
in HTML, exactly due to changing where the newlines are stored inside the file.
I believe this change brings the best of both worlds by changing the significant
part of the HTML markup so the validator is happy, and keeping the stuff that
gtkimhtml.c needs in the first line.
--- a/libpurple/log.c Wed Oct 09 20:12:01 2019 +0200
+++ b/libpurple/log.c Wed Oct 09 20:39:11 2019 +0200
@@ -1395,7 +1395,7 @@
date = purple_date_format_full(localtime(&log->time));
- written += fprintf(data->file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n");
+ written += fprintf(data->file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html><head>");
written += fprintf(data->file, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
written += fprintf(data->file, "<title>");
if (log->type == PURPLE_LOG_SYSTEM)
@@ -1406,8 +1406,8 @@
log->name, date, purple_account_get_username(log->account), prpl);
written += fprintf(data->file, "%s", header);
- written += fprintf(data->file, "</title>\n</head>\n<body>\n");
- written += fprintf(data->file, "<h1>%s</h1>\n<p>\n", header);
+ written += fprintf(data->file, "</title></head><body>");
+ written += fprintf(data->file, "<h1>%s</h1><p>\n", header);
g_free(header);
}