[evolution/gnome-3-6] Bug #686212 - Cannot print html mails with defined <style />
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-6] Bug #686212 - Cannot print html mails with defined <style />
- Date: Mon, 26 Nov 2012 12:58:28 +0000 (UTC)
commit f99cc804a69148b58fa3d00df2877df9cfd9d67a
Author: Milan Crha <mcrha redhat com>
Date: Mon Nov 26 13:58:05 2012 +0100
Bug #686212 - Cannot print html mails with defined <style />
em-format/e-mail-formatter-text-html.c | 36 +++++++++++++++++++++----------
1 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/em-format/e-mail-formatter-text-html.c b/em-format/e-mail-formatter-text-html.c
index 71c73f9..8b23a18 100644
--- a/em-format/e-mail-formatter-text-html.c
+++ b/em-format/e-mail-formatter-text-html.c
@@ -85,8 +85,17 @@ get_tag (const gchar *utf8_string,
t = closing;
while (t) {
c = g_utf8_get_char (t);
- if (c == '<')
- break;
+ if (c == '<') {
+ if (t[1] == '!' && t[2] == '-' && t[3] == '-') {
+ /* it's a comment start, read until the end of "-->" */
+ gchar *end = strstr (t + 4, "-->");
+ if (end) {
+ t = end + 2;
+ } else
+ break;
+ } else
+ break;
+ }
t = g_utf8_find_next_char (t, NULL);
}
@@ -111,7 +120,7 @@ get_tag (const gchar *utf8_string,
/* Broken HTML? */
if (!has_end)
- return g_strndup (opening, closing - opening + 1);
+ return NULL;
do {
c = g_utf8_get_char (t);
@@ -130,7 +139,7 @@ get_tag (const gchar *utf8_string,
}
/* Broken HTML? */
- return g_strndup (opening, closing - opening + 1);
+ return NULL;
}
static gboolean
@@ -171,14 +180,19 @@ emfe_text_html_format (EMailFormatterExtension *extension,
g_object_unref (decoded_stream);
+ if (!g_utf8_validate (string->str, -1, NULL)) {
+ gchar *valid_utf8;
+
+ valid_utf8 = e_util_utf8_make_valid (string->str);
+ g_string_free (string, TRUE);
+ string = g_string_new (valid_utf8);
+ g_free (valid_utf8);
+ }
+
tags = NULL;
pos = string->str;
valid = FALSE;
- if (!g_utf8_validate (string->str, -1, NULL)) {
- /* FIXME - What do we do if the string is not UTF-8 valid? */
- }
-
do {
gchar *tmp;
gchar *closing;
@@ -220,9 +234,6 @@ emfe_text_html_format (EMailFormatterExtension *extension,
} while (pos);
- if (tags)
- printf ("\n\n**%s**\n\n", (gchar *) tags->data);
-
/* Something's wrong, let's write the entire HTML and hope
* that WebKit can handle it */
if (!valid) {
@@ -245,7 +256,8 @@ emfe_text_html_format (EMailFormatterExtension *extension,
g_string_prepend (string, "<div ");
for (iter = tags; iter; iter = iter->next) {
- g_string_prepend (string, iter->data);
+ if (iter->data)
+ g_string_prepend (string, iter->data);
}
g_list_free_full (tags, g_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]