aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-filter-crlf.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-06-30 02:09:45 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-06-30 02:09:45 +0800
commitf57c6219924045efc8a6f9f3107d5369a2de7a66 (patch)
tree3ed1f2745374f782df216388c9b0227eeada8b70 /camel/camel-mime-filter-crlf.c
parentf3ad1a30ae1dc55633b92e8175ea73492cdf2f37 (diff)
downloadgsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.tar
gsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.tar.gz
gsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.tar.bz2
gsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.tar.lz
gsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.tar.xz
gsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.tar.zst
gsoc2013-evolution-f57c6219924045efc8a6f9f3107d5369a2de7a66.zip
Build the test-crlf test program.
2001-06-29 Jeffrey Stedfast <fejj@ximian.com> * tests/mime-filter/Makefile.am: Build the test-crlf test program. * tests/mime-filter/test-crlf.c: New test suite for the crlf filter. * camel-mime-filter-crlf.c (filter): Fixed to correctly encode and decode dots. svn path=/trunk/; revision=10602
Diffstat (limited to 'camel/camel-mime-filter-crlf.c')
-rw-r--r--camel/camel-mime-filter-crlf.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/camel/camel-mime-filter-crlf.c b/camel/camel-mime-filter-crlf.c
index 58623f2ac7..6977b04878 100644
--- a/camel/camel-mime-filter-crlf.c
+++ b/camel/camel-mime-filter-crlf.c
@@ -66,25 +66,30 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
CamelMimeFilterCRLF *crlf = (CamelMimeFilterCRLF *)f;
gboolean do_dots;
char *p, *q;
-
+
do_dots = crlf->mode == CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS;
-
+
if (crlf->direction == CAMEL_MIME_FILTER_CRLF_ENCODE) {
camel_mime_filter_set_size (f, 3 * len, FALSE);
-
+
p = in;
q = f->outbuf;
while (p < in + len) {
- if (*p == '\n')
+ if (*p == '\n') {
+ crlf->saw_lf = TRUE;
*q++ = '\r';
- else
- if (do_dots && *p == '.' && (p == in || *(p - 1) == '\n'))
+ } else {
+ if (do_dots && *p == '.' && crlf->saw_lf)
*q++ = '.';
+
+ crlf->saw_lf = FALSE;
+ }
+
*q++ = *p++;
}
} else {
camel_mime_filter_set_size (f, len, FALSE);
-
+
p = in;
q = f->outbuf;
while (p < in + len) {
@@ -92,30 +97,35 @@ filter (CamelMimeFilter *f, char *in, size_t len, size_t prespace,
crlf->saw_cr = TRUE;
} else {
if (crlf->saw_cr) {
- if (*p != '\n')
- *q++ = '\r';
crlf->saw_cr = FALSE;
+
+ if (*p == '\n') {
+ crlf->saw_lf = TRUE;
+ *q++ = *p++;
+ continue;
+ } else
+ *q++ = '\r';
}
+
*q++ = *p;
}
-
- if (do_dots) {
- if (*p == '.' && (p == in || *(p - 1) == '\n')) {
+
+ if (do_dots && *p == '.') {
+ if (crlf->saw_lf) {
crlf->saw_dot = TRUE;
- } else {
- if (crlf->saw_dot) {
- if (*p == '.')
- p++;
- crlf->saw_dot = FALSE;
- }
- *q++ = *p;
+ crlf->saw_lf = FALSE;
+ p++;
+ } else if (crlf->saw_dot) {
+ crlf->saw_dot = FALSE;
}
}
-
+
+ crlf->saw_lf = FALSE;
+
p++;
}
}
-
+
*out = f->outbuf;
*outlen = q - f->outbuf;
*outprespace = f->outpre;
@@ -135,6 +145,8 @@ reset (CamelMimeFilter *f)
CamelMimeFilterCRLF *crlf = (CamelMimeFilterCRLF *)f;
crlf->saw_cr = FALSE;
+ crlf->saw_lf = TRUE;
+ crlf->saw_dot = FALSE;
}
CamelMimeFilter *
@@ -145,6 +157,8 @@ camel_mime_filter_crlf_new (CamelMimeFilterCRLFDirection direction, CamelMimeFil
crlf->direction = direction;
crlf->mode = mode;
crlf->saw_cr = FALSE;
+ crlf->saw_lf = TRUE;
+ crlf->saw_dot = FALSE;
return (CamelMimeFilter *)crlf;
}