aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-11-26 20:56:46 +0800
committerMilan Crha <mcrha@redhat.com>2012-11-26 20:56:46 +0800
commite2c15bd1d56e6a66275f1f50431e9143d2e50247 (patch)
tree1fba856362ea4f3cd4f6479d9a5d3257078cc451 /em-format
parent51ca0952f4b694f25cdfe774dfd8498c916101a7 (diff)
downloadgsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.tar
gsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.tar.gz
gsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.tar.bz2
gsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.tar.lz
gsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.tar.xz
gsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.tar.zst
gsoc2013-evolution-e2c15bd1d56e6a66275f1f50431e9143d2e50247.zip
Bug #686212 - Cannot print html mails with defined <style>
Diffstat (limited to 'em-format')
-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);