summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-03-10 08:55:54 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-03-10 09:00:06 (GMT)
commitddf85fb13b49c218a8c33d6eda52d23a888aba60 (patch) (side-by-side diff)
tree1942d2b2d9a1f16fe8b7beee5ba259cdeb6dd3ea
parent57d9a048fecafa6ba73810c14802720b2873264d (diff)
downloadmailutils-ddf85fb13b49c218a8c33d6eda52d23a888aba60.tar.gz
mailutils-ddf85fb13b49c218a8c33d6eda52d23a888aba60.tar.bz2
Fix encoding of empty input by DOT filter.
* libmailutils/filter/dot.c (_dot_encoder): Don't emit additional empty line on empty input (i.e. if mu_filter_lastbuf arrives when dfa is in dot_encode_init state). * libmailutils/tests/dot.at: Test empty input.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libmailutils/filter/dot.c3
-rw-r--r--libmailutils/tests/dot.at8
-rw-r--r--libmailutils/tests/testsuite.at2
3 files changed, 11 insertions, 2 deletions
diff --git a/libmailutils/filter/dot.c b/libmailutils/filter/dot.c
index 1e41df1..d3a3aab 100644
--- a/libmailutils/filter/dot.c
+++ b/libmailutils/filter/dot.c
@@ -178,7 +178,7 @@ _dot_encoder (void *xd,
size_t isize;
char *optr;
size_t osize;
- int *state = xd;
+ enum dot_encode_state *state = xd;
switch (cmd)
{
@@ -229,6 +229,7 @@ _dot_encoder (void *xd,
{
switch (*state)
{
+ case dot_encode_init:
case dot_encode_lf:
if (j + 2 > osize)
result = mu_filter_again;
diff --git a/libmailutils/tests/dot.at b/libmailutils/tests/dot.at
index 1516a1b..7be7bb6 100644
--- a/libmailutils/tests/dot.at
+++ b/libmailutils/tests/dot.at
@@ -48,6 +48,14 @@ end.
])
AT_CLEANUP
+AT_SETUP([DOT empty input])
+AT_KEYWORDS([DOT empty input])
+AT_CHECK([fltst dot encode read < /dev/null],
+[0],
+[.
+])
+AT_CLEANUP
+
AT_SETUP([DOT reversibility])
AT_KEYWORDS([filter dot])
AT_CHECK([
diff --git a/libmailutils/tests/testsuite.at b/libmailutils/tests/testsuite.at
index db284fd..5e302ee 100644
--- a/libmailutils/tests/testsuite.at
+++ b/libmailutils/tests/testsuite.at
@@ -215,9 +215,9 @@ m4_include([hdrcpy.at])
m4_include([linecon.at])
m4_include([htmlent.at])
m4_include([xml.at])
+m4_include([dot.at])
m4_include([crlf.at])
m4_include([crlfdot.at])
-m4_include([dot.at])
AT_BANNER(Debug Specification)
m4_include([debugspec.at])

Return to:

Send suggestions and report system problems to the System administrator.