aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-26 20:58:05 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-26 20:58:05 +0800
commitf99cc804a69148b58fa3d00df2877df9cfd9d67a (patch)
treed053d864526dfff596faac2463088c7a0a81a358
parent014787726484baff39dca4f8a3c5d71b72dcee9a (diff)
downloadgsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.tar
gsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.tar.gz
gsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.tar.bz2
gsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.tar.lz
gsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.tar.xz
gsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.tar.zst
gsoc2013-evolution-f99cc804a69148b58fa3d00df2877df9cfd9d67a.zip
Bug #686212 - Cannot print html mails with defined <style />
-rw-r--r--em-format/e-mail-formatter-text-html.c36
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 71c73f9266..8b23a1897e 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);