summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-03-02 23:33:59 +0200
committerSergey Poznyakoff <gray@gnu.org>2019-03-02 23:40:08 +0200
commitbc61f890ce68761d7b713508cdb97cb08f058aa3 (patch)
treeda9e1dc9a4977af7d5bd4d0c9f5e120d05469ffe
parent4d422ec9bf22cb45785ed7a17a60d0d7b2bb013b (diff)
downloadmailutils-bc61f890ce68761d7b713508cdb97cb08f058aa3.tar.gz
mailutils-bc61f890ce68761d7b713508cdb97cb08f058aa3.tar.bz2
Fix the dot filter decoding
* libmailutils/filter/dot.c (_dot_decoder): Don't emit extra newline at the "\n.\n" marker. * libmailutils/stream/stream.c (mu_stream_seterr): Don't treat ENOSYS as fatal error. * libmailutils/tests/dot.at: New file. * libmailutils/tests/testsuite.at: Include dot.at. * libmailutils/tests/Makefile.am: Add dot.at * testsuite/smtp-msg.at: Remove extra newline from the expected output. * testsuite/smtp-str.at: Likewise.
-rw-r--r--examples/mta.c2
-rw-r--r--libmailutils/filter/dot.c17
-rw-r--r--libmailutils/stream/stream.c1
-rw-r--r--libmailutils/tests/Makefile.am1
-rw-r--r--libmailutils/tests/dot.at64
-rw-r--r--libmailutils/tests/testsuite.at1
-rw-r--r--testsuite/smtp-msg.at1
-rw-r--r--testsuite/smtp-str.at1
8 files changed, 78 insertions, 10 deletions
diff --git a/examples/mta.c b/examples/mta.c
index 4ea33caad..57e6bc3e8 100644
--- a/examples/mta.c
+++ b/examples/mta.c
@@ -726,7 +726,7 @@ smtp (mu_stream_t str)
if (rc)
{
mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_create",
- "CRLFDOT", rc);
+ "DOT", rc);
exit (EX_UNAVAILABLE);
}
smtp_reply (str, 354,
diff --git a/libmailutils/filter/dot.c b/libmailutils/filter/dot.c
index cbba4bcf5..1e41df12c 100644
--- a/libmailutils/filter/dot.c
+++ b/libmailutils/filter/dot.c
@@ -125,19 +125,22 @@ _dot_decoder (void *xd,
optr = iobuf->output;
osize = iobuf->osize;
- for (i = j = 0; *pstate != dot_decode_end && i < isize && j < osize; i++)
+ for (i = j = 0; i < isize && j < osize; i++)
{
unsigned char c = *iptr++;
int curstate = *pstate;
*pstate = new_decode_state (curstate, c);
- if (!(c == '.' && (curstate == dot_decode_init ||
- curstate == dot_decode_lf)))
- optr[j++] = c;
+ if (c == '.'
+ && (curstate == dot_decode_init || curstate == dot_decode_lf))
+ continue;
+ if (*pstate == dot_decode_end)
+ {
+ iobuf->eof = 1;
+ break;
+ }
+ optr[j++] = c;
}
-
- if (*pstate == dot_decode_end)
- iobuf->eof = 1;
iobuf->isize = i;
iobuf->osize = j;
diff --git a/libmailutils/stream/stream.c b/libmailutils/stream/stream.c
index 8c9cbb6e0..ca66d8251 100644
--- a/libmailutils/stream/stream.c
+++ b/libmailutils/stream/stream.c
@@ -97,6 +97,7 @@ mu_stream_seterr (struct _mu_stream *stream, int code, int perm)
{
case 0:
case EAGAIN:
+ case ENOSYS:
case EINPROGRESS:
break;
diff --git a/libmailutils/tests/Makefile.am b/libmailutils/tests/Makefile.am
index b264bef15..26137df97 100644
--- a/libmailutils/tests/Makefile.am
+++ b/libmailutils/tests/Makefile.am
@@ -96,6 +96,7 @@ TESTSUITE_AT = \
base64e.at\
debugspec.at\
decode2047.at\
+ dot.at\
crlf.at\
crlfdot.at\
ctm.at\
diff --git a/libmailutils/tests/dot.at b/libmailutils/tests/dot.at
new file mode 100644
index 000000000..1516a1bf8
--- /dev/null
+++ b/libmailutils/tests/dot.at
@@ -0,0 +1,64 @@
+# This file is part of GNU Mailutils. -*- Autotest -*-
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
+#
+# GNU Mailutils is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([DOT encode])
+AT_KEYWORDS([filter encode dot])
+AT_CHECK([
+AT_DATA([input],[line 1
+.line 2
+end.
+])
+fltst dot encode read < input
+],
+[0],
+[line 1
+..line 2
+end.
+.
+])
+AT_CLEANUP
+
+AT_SETUP([DOT decode])
+AT_KEYWORDS([filter decode dot])
+AT_CHECK([
+AT_DATA([input],[line 1
+..line 2
+end.
+.
+])
+fltst dot decode read < input
+],
+[0],
+[line 1
+.line 2
+end.
+])
+AT_CLEANUP
+
+AT_SETUP([DOT reversibility])
+AT_KEYWORDS([filter dot])
+AT_CHECK([
+AT_DATA([input],[.
+..
+...LIN
+....
+.....
+])
+fltst dot encode read < input | fltst dot decode read | cmp input -
+],
+[0])
+AT_CLEANUP
+
diff --git a/libmailutils/tests/testsuite.at b/libmailutils/tests/testsuite.at
index e641c78fc..d155d0116 100644
--- a/libmailutils/tests/testsuite.at
+++ b/libmailutils/tests/testsuite.at
@@ -216,6 +216,7 @@ m4_include([htmlent.at])
m4_include([xml.at])
m4_include([crlf.at])
m4_include([crlfdot.at])
+m4_include([dot.at])
AT_BANNER(Debug Specification)
m4_include([debugspec.at])
diff --git a/testsuite/smtp-msg.at b/testsuite/smtp-msg.at
index 94fee75e4..689ce9e59 100644
--- a/testsuite/smtp-msg.at
+++ b/testsuite/smtp-msg.at
@@ -52,7 +52,6 @@ ENVELOPE TO: <gray@example.org>
4: Omnis enim res, quae dando non deficit,
5: dum habetur et non datur, nondum habetur,
6: quomodo habenda est.
- 7:
END OF MESSAGE
])
diff --git a/testsuite/smtp-str.at b/testsuite/smtp-str.at
index dffc9e3de..0940299ed 100644
--- a/testsuite/smtp-str.at
+++ b/testsuite/smtp-str.at
@@ -53,7 +53,6 @@ ENVELOPE TO: <gray@example.org>
4: Omnis enim res, quae dando non deficit,
5: dum habetur et non datur, nondum habetur,
6: quomodo habenda est.
- 7:
END OF MESSAGE
])

Return to:

Send suggestions and report system problems to the System administrator.