aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-03-10 00:41:47 +0800
committerMilan Crha <mcrha@redhat.com>2011-03-10 00:41:47 +0800
commiteef2191a3a4fc8bb358b04a1eb0c10ba5f34e611 (patch)
tree26a41b417375f215e3618786de49d6b151a042bf /em-format
parent46a52a54c4c7b3559f135a40d3bd77e644ce73ad (diff)
downloadgsoc2013-evolution-eef2191a3a4fc8bb358b04a1eb0c10ba5f34e611.tar.gz
gsoc2013-evolution-eef2191a3a4fc8bb358b04a1eb0c10ba5f34e611.tar.zst
gsoc2013-evolution-eef2191a3a4fc8bb358b04a1eb0c10ba5f34e611.zip
Bug #586461 - Remove signature also from HTML formatted emails on reply
Diffstat (limited to 'em-format')
-rw-r--r--em-format/em-format-quote.c22
-rw-r--r--em-format/em-stripsig-filter.c13
-rw-r--r--em-format/em-stripsig-filter.h3
3 files changed, 32 insertions, 6 deletions
diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c
index e2eb9d382b..e54ecf60ac 100644
--- a/em-format/em-format-quote.c
+++ b/em-format/em-format-quote.c
@@ -623,7 +623,7 @@ emfq_text_plain (EMFormat *emf,
filtered_stream = camel_stream_filter_new (stream);
if ((emfq->flags & EM_FORMAT_QUOTE_KEEP_SIG) == 0) {
- sig_strip = em_stripsig_filter_new ();
+ sig_strip = em_stripsig_filter_new (TRUE);
camel_stream_filter_add (
CAMEL_STREAM_FILTER (filtered_stream), sig_strip);
g_object_unref (sig_strip);
@@ -674,6 +674,7 @@ emfq_text_enriched (EMFormat *emf,
camel_stream_write_string (stream, "<br><hr><br>", cancellable, NULL);
em_format_format_text (
emf, filtered_stream, CAMEL_DATA_WRAPPER (part), cancellable);
+ camel_stream_flush (filtered_stream, cancellable, NULL);
g_object_unref (filtered_stream);
}
@@ -687,8 +688,23 @@ emfq_text_html (EMFormat *emf,
{
camel_stream_write_string (
stream, "\n<!-- text/html -->\n", cancellable, NULL);
- em_format_format_text (
- emf, stream, (CamelDataWrapper *)part, cancellable);
+
+ if ((EM_FORMAT_QUOTE (emf)->flags & EM_FORMAT_QUOTE_KEEP_SIG) == 0) {
+ CamelMimeFilter *sig_strip;
+ CamelStream *filtered_stream;
+
+ filtered_stream = camel_stream_filter_new (stream);
+
+ sig_strip = em_stripsig_filter_new (FALSE);
+ camel_stream_filter_add (CAMEL_STREAM_FILTER (filtered_stream), sig_strip);
+ g_object_unref (sig_strip);
+
+ em_format_format_text (emf, filtered_stream, (CamelDataWrapper *) part, cancellable);
+ camel_stream_flush (filtered_stream, cancellable, NULL);
+ g_object_unref (filtered_stream);
+ } else {
+ em_format_format_text (emf, stream, (CamelDataWrapper *)part, cancellable);
+ }
}
static void
diff --git a/em-format/em-stripsig-filter.c b/em-format/em-stripsig-filter.c
index 38b74b8f9f..bbca2f6161 100644
--- a/em-format/em-stripsig-filter.c
+++ b/em-format/em-stripsig-filter.c
@@ -61,6 +61,9 @@ strip_signature (CamelMimeFilter *filter,
if ((inend - inptr) >= 4 && !strncmp (inptr, "-- \n", 4)) {
start = inptr;
inptr += 4;
+ } else if (!stripsig->text_plain_only && (inend - inptr) >= 7 && !g_ascii_strncasecmp (inptr, "-- <BR>", 7)) {
+ start = inptr;
+ inptr += 7;
} else {
while (inptr < inend && *inptr != '\n')
inptr++;
@@ -142,13 +145,19 @@ em_stripsig_filter_init (EMStripSigFilter *filter)
/**
* em_stripsig_filter_new:
+ * @text_plain_only: Whether should look for a text/plain signature
+ * delimiter "-- \n" only or also an HTML signature delimiter "-- <BR>".
*
* Creates a new stripsig filter.
*
* Returns a new stripsig filter.
**/
CamelMimeFilter *
-em_stripsig_filter_new (void)
+em_stripsig_filter_new (gboolean text_plain_only)
{
- return g_object_new (EM_TYPE_STRIPSIG_FILTER, NULL);
+ EMStripSigFilter *filter = g_object_new (EM_TYPE_STRIPSIG_FILTER, NULL);
+
+ filter->text_plain_only = text_plain_only;
+
+ return CAMEL_MIME_FILTER (filter);
}
diff --git a/em-format/em-stripsig-filter.h b/em-format/em-stripsig-filter.h
index f841727693..5ca4491b4f 100644
--- a/em-format/em-stripsig-filter.h
+++ b/em-format/em-stripsig-filter.h
@@ -53,6 +53,7 @@ struct _EMStripSigFilter {
CamelMimeFilter parent;
guint32 midline:1;
+ guint32 text_plain_only:1;
};
struct _EMStripSigFilterClass {
@@ -61,7 +62,7 @@ struct _EMStripSigFilterClass {
GType em_stripsig_filter_get_type (void);
CamelMimeFilter *
- em_stripsig_filter_new (void);
+ em_stripsig_filter_new (gboolean text_plain_only);
G_END_DECLS