aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorPeter Williams <peterw@ximian.com>2001-06-29 04:35:43 +0800
committerPeter Williams <peterw@src.gnome.org>2001-06-29 04:35:43 +0800
commit6ffa930086b903dbd8fed3543f5e4ed762b6e8d1 (patch)
tree805bc825e07162f42996776921d770efe44b4b69 /camel
parentdacae0532fb39cee00b4f8ccfa8157d3a31b3a80 (diff)
downloadgsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.tar
gsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.tar.gz
gsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.tar.bz2
gsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.tar.lz
gsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.tar.xz
gsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.tar.zst
gsoc2013-evolution-6ffa930086b903dbd8fed3543f5e4ed762b6e8d1.zip
Add a CamelMimeFilterStripHeader that removes a header from mime output. Used
by sendmail to strip the BCC from the email while still sending to the BCC recipients. camel: 2001-06-28 Peter Williams <peterw@ximian.com> * camel-mime-filter-stripheader.c: New file. Filter that strips a header from mime output. * camel-mime-filter-stripheader.h: New file. Header for the above. * providers/smtp/camel-smtp-transport.c (smtp_data): Use the stripheader filter to remove the "Bcc" header. * Makefile.am: Add the stripheader files. * tests/lib/Makefile.am (INCLUDES): Get this to compile again. * tests/mime-filter/test-stripheader.c: New file. Test suite for the CamelMimeFilterStripHeader. * tests/mime-filter/Makefile.am: New test section: mime filters. mail: 2001-06-28 Peter Williams <peterw@ximian.com> * mail-ops.c (mail_send_message): Revert fejj's Bcc header removal; this unsets the BCC recipients and so doesn't send to the Bcc'd people at all. svn path=/trunk/; revision=10576
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog19
-rw-r--r--camel/Makefile.am2
-rw-r--r--camel/camel-mime-filter-stripheader.c181
-rw-r--r--camel/camel-mime-filter-stripheader.h54
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c5
-rw-r--r--camel/tests/Makefile.am2
-rw-r--r--camel/tests/lib/Makefile.am2
-rw-r--r--camel/tests/mime-filter/.cvsignore7
-rw-r--r--camel/tests/mime-filter/Makefile.am36
-rw-r--r--camel/tests/mime-filter/stripheader-1.in6
-rw-r--r--camel/tests/mime-filter/stripheader-1.out5
-rw-r--r--camel/tests/mime-filter/stripheader-2.in8
-rw-r--r--camel/tests/mime-filter/stripheader-2.out6
-rw-r--r--camel/tests/mime-filter/stripheader-3.in9
-rw-r--r--camel/tests/mime-filter/stripheader-3.out7
-rw-r--r--camel/tests/mime-filter/stripheader-4.in7
-rw-r--r--camel/tests/mime-filter/stripheader-4.out5
-rw-r--r--camel/tests/mime-filter/stripheader-5.in9
-rw-r--r--camel/tests/mime-filter/stripheader-5.out5
-rw-r--r--camel/tests/mime-filter/stripheader-6.in15
-rw-r--r--camel/tests/mime-filter/stripheader-6.out6
-rw-r--r--camel/tests/mime-filter/test-stripheader.c131
22 files changed, 524 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 09e4973925..a5b8f189cf 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,22 @@
+2001-06-28 Peter Williams <peterw@ximian.com>
+
+ * camel-mime-filter-stripheader.c: New file. Filter that strips a
+ header from mime output.
+
+ * camel-mime-filter-stripheader.h: New file. Header for the above.
+
+ * providers/smtp/camel-smtp-transport.c (smtp_data): Use the stripheader
+ filter to remove the "Bcc" header.
+
+ * Makefile.am: Add the stripheader files.
+
+ * tests/lib/Makefile.am (INCLUDES): Get this to compile again.
+
+ * tests/mime-filter/test-stripheader.c: New file. Test suite for
+ the CamelMimeFilterStripHeader.
+
+ * tests/mime-filter/Makefile.am: New test section: mime filters.
+
2001-06-28 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-utils.c (header_decode_param_list): Fix a memory
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 4c2d34261a..e8e0253efb 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -52,6 +52,7 @@ libcamel_la_SOURCES = \
camel-mime-filter-index.c \
camel-mime-filter-linewrap.c \
camel-mime-filter-save.c \
+ camel-mime-filter-stripheader.c \
camel-mime-filter.c \
camel-mime-message.c \
camel-mime-parser.c \
@@ -136,6 +137,7 @@ libcamelinclude_HEADERS = \
camel-mime-filter-index.h \
camel-mime-filter-linewrap.h \
camel-mime-filter-save.h \
+ camel-mime-filter-stripheader.h \
camel-mime-filter.h \
camel-mime-message.h \
camel-mime-parser.h \
diff --git a/camel/camel-mime-filter-stripheader.c b/camel/camel-mime-filter-stripheader.c
new file mode 100644
index 0000000000..5c78bf459c
--- /dev/null
+++ b/camel/camel-mime-filter-stripheader.c
@@ -0,0 +1,181 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2000 Ximian, Inc.
+ *
+ * Authors: Dan Winship <danw@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
+ * Peter Williams <peterw@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <ctype.h>
+#include <string.h>
+
+#include "camel-mime-filter-stripheader.h"
+
+static void filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
+ char **out, size_t *outlen, size_t *outprespace);
+static void complete (CamelMimeFilter *f, char *in, size_t len,
+ size_t prespace, char **out, size_t *outlen,
+ size_t *outprespace);
+static void reset (CamelMimeFilter *f);
+
+
+static void
+camel_mime_filter_stripheader_init (CamelMimeFilterStripHeader *cmf)
+{
+ cmf->seen_eoh = FALSE;
+ cmf->in_header = FALSE;
+ cmf->header = NULL;
+ cmf->header_len = 0;
+}
+
+static void
+camel_mime_filter_stripheader_finalize (CamelMimeFilterStripHeader *cmf)
+{
+ g_free (cmf->header);
+}
+
+static void
+camel_mime_filter_stripheader_class_init (CamelMimeFilterStripHeaderClass *klass)
+{
+ CamelMimeFilterClass *mime_filter_class =
+ (CamelMimeFilterClass *) klass;
+
+ mime_filter_class->filter = filter;
+ mime_filter_class->complete = complete;
+ mime_filter_class->reset = reset;
+}
+
+CamelType
+camel_mime_filter_stripheader_get_type (void)
+{
+ static CamelType type = CAMEL_INVALID_TYPE;
+
+ if (type == CAMEL_INVALID_TYPE) {
+ type = camel_type_register (camel_mime_filter_get_type(), "CamelMimeFilterStripHeader",
+ sizeof (CamelMimeFilterStripHeader),
+ sizeof (CamelMimeFilterStripHeaderClass),
+ (CamelObjectClassInitFunc) camel_mime_filter_stripheader_class_init,
+ NULL,
+ (CamelObjectInitFunc) camel_mime_filter_stripheader_init,
+ (CamelObjectFinalizeFunc) camel_mime_filter_stripheader_finalize);
+ }
+
+ return type;
+}
+
+static void
+filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
+ char **out, size_t *outlen, size_t *outprespace)
+{
+ CamelMimeFilterStripHeader *sh = (CamelMimeFilterStripHeader *)f;
+ char *p, *q;
+ int left;
+
+ /* all done? */
+ if (sh->seen_eoh) {
+ *out = in;
+ *outlen = len;
+ *outprespace = prespace;
+ return;
+ }
+
+ /* nope */
+
+ camel_mime_filter_set_size (f, len, FALSE);
+
+ p = in;
+ q = f->outbuf;
+
+ while (p < (in + len)) {
+ if (*p == '\n') {
+ left = in + len - p;
+
+ /* Not enough left to do anything useful. */
+ if (left < (sh->header_len + 3)) {
+ camel_mime_filter_backup (f, p, left);
+ break;
+ }
+
+ /* MIME-ese for 'end of headers'. Our work here is done, */
+ if (!strncmp (p, "\n\n", 2)) {
+
+ if (sh->in_header) {
+ /* we've already got a \n */
+ p++;
+ left--;
+ }
+
+ sh->seen_eoh = TRUE;
+ memcpy (q, p, left);
+ q += left;
+ break;
+ }
+
+ /* (Maybe) Grab this \n */
+ if (!sh->in_header)
+ *q++ = *p;
+ p++;
+
+ if (!strncmp (p, sh->header, sh->header_len) && p[sh->header_len] == ':')
+ /* ok it seems we /are/ in the header */
+ sh->in_header = TRUE;
+ else if (!isspace ((int)(*p)))
+ /* if we were in a header and we are on a space
+ * in_header will remain true...*/
+ sh->in_header = FALSE;
+
+ }
+
+ /* ok then */
+ if (!sh->in_header)
+ *q++ = *p;
+ p++;
+ }
+
+ *out = f->outbuf;
+ *outlen = q - f->outbuf;
+ *outprespace = f->outpre;
+}
+
+static void
+complete (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
+ char **out, size_t *outlen, size_t *outprespace)
+{
+ if (len)
+ filter (f, in, len, prespace, out, outlen, outprespace);
+}
+
+static void
+reset (CamelMimeFilter *f)
+{
+ CamelMimeFilterStripHeader *sh = (CamelMimeFilterStripHeader *)f;
+
+ sh->seen_eoh = FALSE;
+ sh->in_header = FALSE;
+}
+
+CamelMimeFilter *
+camel_mime_filter_stripheader_new (const gchar *header)
+{
+ CamelMimeFilterStripHeader *sh = CAMEL_MIME_FILTER_STRIPHEADER(camel_object_new (CAMEL_MIME_FILTER_STRIPHEADER_TYPE));
+
+ sh->header = g_strdup (header);
+ sh->header_len = strlen (header);
+
+ return (CamelMimeFilter *)sh;
+}
diff --git a/camel/camel-mime-filter-stripheader.h b/camel/camel-mime-filter-stripheader.h
new file mode 100644
index 0000000000..1a22dece2d
--- /dev/null
+++ b/camel/camel-mime-filter-stripheader.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2000 Ximian Inc.
+ *
+ * Authors: Dan Winship <danw@ximian.com>
+ * Jeffrey Stedfast <fejj@ximian.com>
+ * Peter Williams <peterw@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _CAMEL_MIME_FILTER_STRIPHEADER_H
+#define _CAMEL_MIME_FILTER_STRIPHEADER_H
+
+#include <camel/camel-mime-filter.h>
+
+#define CAMEL_MIME_FILTER_STRIPHEADER_TYPE (camel_mime_filter_stripheader_get_type ())
+#define CAMEL_MIME_FILTER_STRIPHEADER(obj) CAMEL_CHECK_CAST (obj, CAMEL_MIME_FILTER_STRIPHEADER_TYPE, CamelMimeFilterStripHeader)
+#define CAMEL_MIME_FILTER_STRIPHEADER_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, CAMEL_MIME_FILTER_STRIPHEADER_TYPE, CamelMimeFilterStripHeaderClass)
+#define CAMEL_IS_MIME_FILTER_STRIPHEADER(obj) CAMEL_CHECK_TYPE (obj, CAMEL_MIME_FILTER_STRIPHEADER_TYPE)
+
+typedef struct _CamelMimeFilterStripHeader CamelMimeFilterStripHeader;
+typedef struct _CamelMimeFilterStripHeaderClass CamelMimeFilterStripHeaderClass;
+
+struct _CamelMimeFilterStripHeader {
+ CamelMimeFilter parent;
+
+ gchar *header;
+ int header_len;
+ gboolean seen_eoh; /* end of headers */
+ gboolean in_header;
+};
+
+struct _CamelMimeFilterStripHeaderClass {
+ CamelMimeFilterClass parent_class;
+};
+
+CamelType camel_mime_filter_stripheader_get_type (void);
+
+CamelMimeFilter *camel_mime_filter_stripheader_new (const gchar *header);
+
+#endif /* ! _CAMEL_MIME_FILTER_STRIPHEADER_H */
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 48b4250185..cf11499074 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -40,6 +40,7 @@
#undef MIN
#undef MAX
#include "camel-mime-filter-crlf.h"
+#include "camel-mime-filter-stripheader.h"
#include "camel-mime-filter-linewrap.h"
#include "camel-stream-filter.h"
#include "camel-smtp-transport.h"
@@ -911,7 +912,7 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi
/* now we can actually send what's important :p */
gchar *cmdbuf, *respbuf = NULL;
CamelStreamFilter *filtered_stream;
- CamelMimeFilter *crlffilter;
+ CamelMimeFilter *crlffilter, *bccfilter;
/* if the message contains 8bit mime parts and the server
doesn't support it, encode 8bit parts to the best
@@ -955,7 +956,9 @@ smtp_data (CamelSmtpTransport *transport, CamelMedium *message, gboolean has_8bi
/* setup stream filtering */
crlffilter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS);
+ bccfilter = camel_mime_filter_stripheader_new ("Bcc");
filtered_stream = camel_stream_filter_new_with_stream (transport->ostream);
+ camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (bccfilter));
camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlffilter));
if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), CAMEL_STREAM (filtered_stream)) == -1) {
diff --git a/camel/tests/Makefile.am b/camel/tests/Makefile.am
index 1d24ebd0ac..e32f2e455f 100644
--- a/camel/tests/Makefile.am
+++ b/camel/tests/Makefile.am
@@ -1,3 +1,3 @@
SUBDIRS = lib \
- message folder stream smime misc
+ message folder stream smime misc mime-filter
diff --git a/camel/tests/lib/Makefile.am b/camel/tests/lib/Makefile.am
index c3da5e37a8..f3a92899b2 100644
--- a/camel/tests/lib/Makefile.am
+++ b/camel/tests/lib/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES = -I$(includedir)
+INCLUDES = -I$(includedir) -I$(top_srcdir) -I$(top_srcdir)/camel
check_LIBRARIES = libcameltest.a
diff --git a/camel/tests/mime-filter/.cvsignore b/camel/tests/mime-filter/.cvsignore
new file mode 100644
index 0000000000..2cee3ea3cb
--- /dev/null
+++ b/camel/tests/mime-filter/.cvsignore
@@ -0,0 +1,7 @@
+.deps
+Makefile
+Makefile.in
+.libs
+*.lo
+*.la
+test-stripheader \ No newline at end of file
diff --git a/camel/tests/mime-filter/Makefile.am b/camel/tests/mime-filter/Makefile.am
new file mode 100644
index 0000000000..a1a3ebb832
--- /dev/null
+++ b/camel/tests/mime-filter/Makefile.am
@@ -0,0 +1,36 @@
+
+INCLUDES = -I$(top_srcdir)/intl -I$(top_srcdir) -I$(top_srcdir)/camel \
+ -I$(includedir) \
+ -I$(top_srcdir)/camel/tests/lib \
+ -DG_LOG_DOMAIN=\"evolution-tests\" \
+ -DSOURCEDIR=\"$(srcdir)\"
+
+LDADD = \
+ $(top_builddir)/camel/libcamel.la \
+ $(top_builddir)/e-util/libeutil.la \
+ $(top_builddir)/libibex/libibex.la \
+ $(GNOME_LIBDIR) \
+ $(top_builddir)/camel/tests/lib/libcameltest.a \
+ $(GNOMEUI_LIBS) $(INTLLIBS) $(EXTRA_GNOME_LIBS)
+
+EXTRA_DIST = \
+ stripheader-1.in \
+ stripheader-1.out \
+ stripheader-2.in \
+ stripheader-2.out \
+ stripheader-3.in \
+ stripheader-3.out \
+ stripheader-4.in \
+ stripheader-4.out \
+ stripheader-5.in \
+ stripheader-5.out \
+ stripheader-6.in \
+ stripheader-6.out
+
+check_PROGRAMS = \
+ test-stripheader
+
+TESTS = test-stripheader
+
+
+
diff --git a/camel/tests/mime-filter/stripheader-1.in b/camel/tests/mime-filter/stripheader-1.in
new file mode 100644
index 0000000000..1db4bf86e3
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-1.in
@@ -0,0 +1,6 @@
+Subject: this is a simple test
+Stripped: of the header stripping filter
+CC: this header should be preserved
+BCC: as should this one
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-1.out b/camel/tests/mime-filter/stripheader-1.out
new file mode 100644
index 0000000000..3101c1e6bd
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-1.out
@@ -0,0 +1,5 @@
+Subject: this is a simple test
+CC: this header should be preserved
+BCC: as should this one
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-2.in b/camel/tests/mime-filter/stripheader-2.in
new file mode 100644
index 0000000000..0a16133bc0
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-2.in
@@ -0,0 +1,8 @@
+Subject: this is a simple test
+Stripped: of the header stripping filter
+CC: this header should be preserved
+Stripped: this header should also be stripped
+BCC: but not this one
+
+This is the body of the message.
+There are several lines to it. Oh boy oh boy. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-2.out b/camel/tests/mime-filter/stripheader-2.out
new file mode 100644
index 0000000000..626dd9c170
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-2.out
@@ -0,0 +1,6 @@
+Subject: this is a simple test
+CC: this header should be preserved
+BCC: but not this one
+
+This is the body of the message.
+There are several lines to it. Oh boy oh boy. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-3.in b/camel/tests/mime-filter/stripheader-3.in
new file mode 100644
index 0000000000..d7c348125b
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-3.in
@@ -0,0 +1,9 @@
+Subject: this is a simple test with a different subject
+Stripped: of the header stripping filter
+Stripped: this header should also be stripped
+CC: this header should be preserved
+BCC: and so should this one
+
+This is the body of the message.
+There are several lines to it. Oh boy oh boy.
+Let's add lots of characters on this line just for fun because I love fun don't you who wouldn't love fun I sure do. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-3.out b/camel/tests/mime-filter/stripheader-3.out
new file mode 100644
index 0000000000..a6da94594e
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-3.out
@@ -0,0 +1,7 @@
+Subject: this is a simple test with a different subject
+CC: this header should be preserved
+BCC: and so should this one
+
+This is the body of the message.
+There are several lines to it. Oh boy oh boy.
+Let's add lots of characters on this line just for fun because I love fun don't you who wouldn't love fun I sure do. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-4.in b/camel/tests/mime-filter/stripheader-4.in
new file mode 100644
index 0000000000..5b0b12e080
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-4.in
@@ -0,0 +1,7 @@
+Subject: this is a simple test
+Stripped: of the header stripping filter
+ ooh look this header spans two lines.
+CC: this header should be preserved
+BCC: as should this one
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-4.out b/camel/tests/mime-filter/stripheader-4.out
new file mode 100644
index 0000000000..3101c1e6bd
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-4.out
@@ -0,0 +1,5 @@
+Subject: this is a simple test
+CC: this header should be preserved
+BCC: as should this one
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-5.in b/camel/tests/mime-filter/stripheader-5.in
new file mode 100644
index 0000000000..99258daec6
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-5.in
@@ -0,0 +1,9 @@
+Subject: this is a simple test
+Stripped: of the header stripping filter
+ ooh look this header spans many
+ lines look at all the freaking lines
+ that this header spans. Wowwww.
+CC: this header should be preserved
+BCC: as should this one
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-5.out b/camel/tests/mime-filter/stripheader-5.out
new file mode 100644
index 0000000000..3101c1e6bd
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-5.out
@@ -0,0 +1,5 @@
+Subject: this is a simple test
+CC: this header should be preserved
+BCC: as should this one
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-6.in b/camel/tests/mime-filter/stripheader-6.in
new file mode 100644
index 0000000000..8bf0e848d0
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-6.in
@@ -0,0 +1,15 @@
+Subject: this is a simple test
+Stripped: of the header stripping filter
+ ooh look this header spans many
+ lines look at all the freaking lines
+ that this header spans. Wowwww.
+Stripped: and then another one to strip that extends fairly far across the page
+Other: let's not use CC here.
+Stripped: oops, I stripped it again
+Stripped: then single line....
+ followed by multi-line. Huzzah.
+NotBCC: definitely not BCC
+ however this one is definitely continued
+Stripped: god-damn look at that stripping.
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/stripheader-6.out b/camel/tests/mime-filter/stripheader-6.out
new file mode 100644
index 0000000000..d8d4202ed0
--- /dev/null
+++ b/camel/tests/mime-filter/stripheader-6.out
@@ -0,0 +1,6 @@
+Subject: this is a simple test
+Other: let's not use CC here.
+NotBCC: definitely not BCC
+ however this one is definitely continued
+
+This is the body of the message. \ No newline at end of file
diff --git a/camel/tests/mime-filter/test-stripheader.c b/camel/tests/mime-filter/test-stripheader.c
new file mode 100644
index 0000000000..ff5446635b
--- /dev/null
+++ b/camel/tests/mime-filter/test-stripheader.c
@@ -0,0 +1,131 @@
+/*
+ test-stripheader.c
+
+ Test the CamelMimeFilterStripHeader class
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "camel-test.h"
+
+#include <camel/camel-stream-fs.h>
+#include <camel/camel-stream-mem.h>
+#include <camel/camel-stream-filter.h>
+#include <camel/camel-mime-filter-stripheader.h>
+
+#define d(x) x
+
+#define NUM_CASES 6
+#define CHUNK_SIZE 32
+
+int
+main(int argc, char **argv)
+{
+ CamelStream *source;
+ CamelStream *correct;
+ CamelStreamFilter *filter;
+ CamelMimeFilter *sh;
+ gchar *work;
+ int i;
+ ssize_t comp_progress, comp_correct_chunk, comp_filter_chunk;
+ int comp_i;
+ char comp_correct[CHUNK_SIZE], comp_filter[CHUNK_SIZE];
+
+ camel_test_init(argc, argv);
+
+ for (i = 0; i < NUM_CASES; i++) {
+ work = g_strdup_printf ("Header stripping filter, test case %d", i);
+ camel_test_start (work);
+ g_free (work);
+
+ camel_test_push ("Initializing objects");
+ work = g_strdup_printf ("%s/stripheader-%d.in", SOURCEDIR, i + 1);
+ source = camel_stream_fs_new_with_name (work, 0, O_RDONLY);
+ if (!source) {
+ camel_test_fail ("Failed to open input case in \"%s\"", work);
+ g_free (work);
+ continue;
+ }
+ g_free (work);
+
+ work = g_strdup_printf ("%s/stripheader-%d.out", SOURCEDIR, i + 1);
+ correct = camel_stream_fs_new_with_name (work, 0, O_RDONLY);
+ if (!correct) {
+ camel_test_fail ("Failed to open correct output in \"%s\"", work);
+ g_free (work);
+ continue;
+ }
+ g_free (work);
+
+ filter = camel_stream_filter_new_with_stream (CAMEL_STREAM (source));
+ if (!filter) {
+ camel_test_fail ("Couldn't create CamelStreamFilter??");
+ continue;
+ }
+
+ sh = camel_mime_filter_stripheader_new ("Stripped");
+ if (!sh) {
+ camel_test_fail ("Couldn't create CamelMimeFilterStripHeader??");
+ continue;
+ }
+
+ camel_stream_filter_add (filter, sh);
+ camel_test_pull ();
+
+ camel_test_push ("Running filter and comparing to correct result");
+
+ comp_progress = 0;
+
+ while (1) {
+ comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE);
+ comp_filter_chunk = 0;
+
+ if (comp_correct_chunk == 0)
+ break;
+
+ while (comp_filter_chunk < comp_correct_chunk) {
+ ssize_t delta;
+
+ delta = camel_stream_read (CAMEL_STREAM (filter),
+ comp_filter + comp_filter_chunk,
+ CHUNK_SIZE - comp_filter_chunk);
+
+ if (delta == 0) {
+ camel_test_fail ("Chunks are different sizes: correct is %d, filter is %d, %d bytes into stream",
+ comp_correct_chunk, comp_filter_chunk, comp_progress);
+ }
+
+ comp_filter_chunk += delta;
+ }
+
+ d(printf ("\n\nCORRECT: >>%.*s<<", comp_correct_chunk, comp_correct);)
+ d(printf ("\nFILTER : >>%.*s<<\n", comp_filter_chunk, comp_filter);)
+
+ for (comp_i = 0; comp_i < comp_filter_chunk; comp_i++) {
+ if (comp_correct[comp_i] != comp_filter[comp_i]) {
+ camel_test_fail ("Difference: correct is %c, filter is %c, %d bytes into stream",
+ comp_correct[comp_i],
+ comp_filter[comp_i],
+ comp_progress + comp_i);
+ }
+ }
+
+ comp_progress += comp_filter_chunk;
+ }
+
+ camel_test_pull ();
+
+ /* inefficient */
+ camel_test_push ("Cleaning up");
+ camel_object_unref (CAMEL_OBJECT (filter));
+ camel_object_unref (CAMEL_OBJECT (correct));
+ camel_object_unref (CAMEL_OBJECT (source));
+ camel_object_unref (CAMEL_OBJECT (sh));
+ camel_test_pull ();
+
+ camel_test_end();
+ }
+
+ return 0;
+}