summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--imap4d/tests/.gitignore7
-rw-r--r--imap4d/tests/Makefile.am8
-rw-r--r--imap4d/tests/ckiconv.c77
-rw-r--r--imap4d/tests/search.at49
-rw-r--r--imap4d/tests/testsuite.at13
-rw-r--r--mail/decode.c2
-rw-r--r--testsuite/spool/DISTFILES1
-rw-r--r--testsuite/spool/search2.mbox219
8 files changed, 365 insertions, 11 deletions
diff --git a/imap4d/tests/.gitignore b/imap4d/tests/.gitignore
index 93f8f46ad..9a0dcda59 100644
--- a/imap4d/tests/.gitignore
+++ b/imap4d/tests/.gitignore
@@ -1,6 +1 @@
-atconfig
-atlocal
-package.m4
-testsuite
-testsuite.dir
-testsuite.log
+ckiconv
diff --git a/imap4d/tests/Makefile.am b/imap4d/tests/Makefile.am
index fdfac4e3f..2e471c20d 100644
--- a/imap4d/tests/Makefile.am
+++ b/imap4d/tests/Makefile.am
@@ -32,7 +32,13 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/package.m4
-#
+## -------------------------- ##
+## Non-installable programs
+## -------------------------- ##
+
+AM_CPPFLAGS = @MU_LIB_COMMON_INCLUDES@
+noinst_PROGRAMS = ckiconv
+LDADD = ${MU_LIB_MAILUTILS}
## ------------ ##
## Test suite. ##
diff --git a/imap4d/tests/ckiconv.c b/imap4d/tests/ckiconv.c
new file mode 100644
index 000000000..34f1dc90a
--- /dev/null
+++ b/imap4d/tests/ckiconv.c
@@ -0,0 +1,77 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 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/>. */
+
+#include <config.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <mailutils/mailutils.h>
+
+static mu_stream_t
+base64stream(int flg)
+{
+ mu_stream_t flt, str;
+ int mode;
+
+ switch (flg)
+ {
+ case MU_STREAM_READ:
+ mode = MU_FILTER_DECODE;
+ str = mu_strin;
+ break;
+
+ case MU_STREAM_WRITE:
+ mode = MU_FILTER_ENCODE;
+ str = mu_strout;
+ break;
+
+ default:
+ abort ();
+ }
+ MU_ASSERT (mu_filter_create (&flt, str, "base64", mode, flg));
+ return flt;
+}
+
+/* usage: ckiconv F T
+
+ Reads base64-encoded stream from standard input, decodes and converts
+ it from character set F to character set T, encodes the result back to
+ base64 and prints it on the standard output.
+
+ Exits with code 0 on success, 1 on failure.
+*/
+
+int
+main (int argc, char **argv)
+{
+ mu_stream_t flt, input, output;
+ char const *iargv[] = { "iconv", NULL, NULL, NULL };
+
+ assert (argc == 3);
+ iargv[1] = argv[1];
+ iargv[2] = argv[2];
+ mu_stdstream_setup (MU_STDSTREAM_RESET_NONE);
+ input = base64stream(MU_STREAM_READ);
+ output = base64stream(MU_STREAM_WRITE);
+ MU_ASSERT (mu_filter_chain_create (&flt, input,
+ MU_FILTER_ENCODE,
+ MU_STREAM_READ,
+ MU_ARRAY_SIZE (iargv) - 1, (char**) iargv));
+ mu_stream_unref (input);
+ MU_ASSERT (mu_stream_copy (output, flt, 0, NULL));
+ mu_stream_destroy (&flt);
+ mu_stream_destroy (&output);
+ return 0;
+}
diff --git a/imap4d/tests/search.at b/imap4d/tests/search.at
index c2a22cd45..d2369cead 100644
--- a/imap4d/tests/search.at
+++ b/imap4d/tests/search.at
@@ -14,12 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
-dnl SEARCH_CHECK([NAME],[KW],[ARG],[OUTPUT])
+dnl SEARCH_CHECK([NAME],[KW],[ARG],[OUTPUT],[COND])
m4_define([SEARCH_CHECK],[
AT_SETUP([$1])
AT_KEYWORDS([search $2])
IMAP4D_CHECK([
-MUT_MBCOPY($abs_top_srcdir/testsuite/spool/search.mbox,INBOX)
+MUT_MBCOPY($abs_top_srcdir/testsuite/spool/SEARCH_MBOX,INBOX)
],
[1 SELECT INBOX
2 SEARCH $3
@@ -38,6 +38,8 @@ AT_CLEANUP
])
dnl ----------------------------------------------------------------------
+m4_pushdef([SEARCH_MBOX],[search.mbox])
+
# <message set> Messages with message sequence numbers
# corresponding to the specified message sequence
# number set
@@ -151,3 +153,46 @@ SEARCH_CHECK([precedence 3],[search22],
[OR FROM corrector (ANSWERED SENTSINCE "30-Jul-2002")],[2 3 4 8])
dnl ----------------------------------------------------------------------
+m4_popdef([SEARCH_MBOX])
+m4_pushdef([SEARCH_MBOX],[search2.mbox])
+
+SEARCH_CHECK([BODY - plain message],[search23],
+[BODY Jujub],
+[1])
+
+SEARCH_CHECK([BODY - MIME level 1],[search24],
+[BODY crocodile],
+[2])
+
+SEARCH_CHECK([BODY - MIME level 1, base64],[search25],
+[BODY incessantly],
+[3])
+
+SEARCH_CHECK([BODY - MIME level 2, base64],[search26],
+[BODY "I have answered three questions"],
+[3])
+
+IMAP4D_WITH_PREREQ(
+[test `echo "seo=" | ckiconv iso-8859-2 utf-8` = "xIXEmQ=="],
+[
+SEARCH_CHECK([BODY CHARSET],[search27],
+[CHARSET utf-8 BODY "Ćwicząc, najwyżej słyszę"],
+[4],
+ICONV_TEST)
+
+SEARCH_CHECK([SUBJECT CHARSET],[search28],
+[CHARSET utf-8 SUBJECT "Tłumaczenie"],
+[4 5],
+ICONV_TEST)
+
+SEARCH_CHECK([BODY CHARSET - MIME message/rfc822],[search29],
+[CHARSET utf-8 BODY "uważasz za słuszne"],
+[5],
+ICONV_TEST)
+])
+
+SEARCH_CHECK([TEXT],[search30],
+[TEXT how],
+[2 3])
+m4_popdef([SEARCH_MBOX])
+
diff --git a/imap4d/tests/testsuite.at b/imap4d/tests/testsuite.at
index 8d2fb4914..0c3646e81 100644
--- a/imap4d/tests/testsuite.at
+++ b/imap4d/tests/testsuite.at
@@ -43,14 +43,25 @@ AT_DATA([input],[$1])dnl
])
imap4d IMAP4D_OPTIONS < input | tr -d '\r'])
+dnl IMAP4D_WITH_PREREQ(COND, TESTS)
+dnl ----------
+dnl Run TESTS if shell CONDitional yields true, otherwise skip them
+dnl
+m4_pushdef([IMAP4D_PREREQ])
+m4_define([IMAP4D_WITH_PREREQ],
+[m4_pushdef([IMAP4D_PREREQ],[$1])
+$2
+m4_popdef([IMAP4D_PREREQ])])
+
dnl ------------------------------------------------------------
dnl IMAP4D_CHECK([PREP], [INPUT], [STDOUT = `'], [STDERR = `'],
dnl [FILTER = `'],[expand])
dnl
-m4_pushdef([IMAP4D_CHECK],[
+m4_define([IMAP4D_CHECK],[
cwd=`pwd`
$1
AT_CHECK([
+m4_if(IMAP4D_PREREQ,,,[IMAP4D_PREREQ || AT_SKIP_TEST])
IMAP4D_RUN([$2],[$6]) | m4_if([$5],,[remove_uidvalidity],[$5])
],
[0],
diff --git a/mail/decode.c b/mail/decode.c
index a9defe00f..15cfd09a5 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -215,7 +215,7 @@ mime_descend (struct mime_descend_closure *closure,
}
}
}
- else if (mu_c_strncasecmp (type, "message/rfc822", strlen (type)) == 0)
+ else if (mu_c_strncasecmp (type, "message/rfc822", 14) == 0)
{
mu_message_t submsg = NULL;
diff --git a/testsuite/spool/DISTFILES b/testsuite/spool/DISTFILES
index f036c77a7..b56d0bc90 100644
--- a/testsuite/spool/DISTFILES
+++ b/testsuite/spool/DISTFILES
@@ -5,6 +5,7 @@ mbox
mime.msg
msg.mbox
search.mbox
+search2.mbox
sieve.mbox
relational.mbox
teaparty.mbox
diff --git a/testsuite/spool/search2.mbox b/testsuite/spool/search2.mbox
new file mode 100644
index 000000000..c10f120ac
--- /dev/null
+++ b/testsuite/spool/search2.mbox
@@ -0,0 +1,219 @@
+From gray@ps.example.org Sat Jan 26 10:28:00 2019
+Date: Sat, 26 Jan 2019 12:28:00 +0200
+From: Gray <gray@ps.example.org>
+Message-Id: <201901261028.fBSKI8N04906@ps.example.org>
+To: Root <root@example.com>
+Subject: Jabberwocky
+
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+`Beware the Jabberwock, my son!
+The jaws that bite, the claws that catch!
+Beware the Jujub bird, and shun
+The frumious Bandersnatch!'
+
+He took his vorpal sword in hand:
+Long time the manxome foe he sought --
+So rested he by the Tumtum gree,
+And stood awhile in thought.
+
+And as in uffish thought he stood,
+The Jabberwock, with eyes of flame,
+Came whiffling through the tulgey wook,
+And burbled as it came!
+
+One, two! One, two! And through and through
+The vorpal blade went snicker-snack!
+He left it dead, and with its head
+He went galumphing back.
+
+`And has thou slain the Jabberwock?
+Come to my arms, my beamish boy!
+O frabjous day! Calloh! Callay!
+He chortled in his joy.
+
+`Twas brillig, and the slithy toves
+Did gyre and gimble in the wabe;
+All mimsy were the borogoves,
+And the mome raths outgrabe.
+
+From gray@ps.example.net Sat Jan 26 10:31:25 2019
+Message-Id: <201901261031.g6CLhIb05086@ps.example.net>
+To: Root <root@example.com>
+Subject: How doth
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+Content-ID: <5082.1026510189.0@ps.example.net>
+Date: Sat, 26 Jan 2019 12:31:25 +0200
+From: Sergey Poznyakoff <gray@ps.example.net>
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii"
+Content-ID: <5082.1026510189.1@ps.example.net>
+Content-Description: How doth
+
+How doth the little crocodile
+Improve his shining tail,
+And pour the waters of the Nile
+On every golden scale!
+
+`How cheerfully he seems to grin,
+How neatly spread his claws,
+And welcome little fishes in
+With gently smiling jaws!
+
+------- =_aaaaaaaaaa0--
+
+From gray@ps.example.net Sat Jan 26 10:38:07 2019
+Message-Id: <201901260938.g6CLowb05126@ps.example.net>
+To: Root <root@example.net>
+Subject: Nested MIME
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+Content-ID: <5122.1026510654.1@ps.example.net>
+Date: Sat, 26 Jan 2019 10:38:10 +0200
+From: Sergey Poznyakoff <gray@ps.example.net>
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii"
+Content-ID: <5122.1026510654.2@ps.example.net>
+Content-Description: Father William Part I
+
+`You are old, Father William,' the young man said,
+`And your hair has become very white;
+And yet you incessantly stand on your head--
+Do you think, at your age, it is right?'
+
+`In my youth,' Father William replied to his son,
+`I feared it might injure the brain;
+But, now that I'm perfectly sure I have none,
+Why, I do it again and again.'
+
+
+------- =_aaaaaaaaaa0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa1"
+Content-ID: <5122.1026510654.3@ps.example.net>
+
+------- =_aaaaaaaaaa1
+Content-Type: text/plain; name="msg.22"
+Content-ID: <5122.1026510654.4@ps.example.net>
+Content-Description: Father William Part II
+Content-Transfer-Encoding: base64
+
+YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhcyBJIG1lbnRpb25lZCBiZWZvcmUsCkFu
+ZCBoYXZlIGdyb3duIG1vc3QgdW5jb21tb25seSBmYXQ7CllldCB5b3UgdHVybmVkIGEgYmFjay1z
+b21lcnNhdWx0IGluIGF0IHRoZSBkb29yLS0KUHJheSwgd2hhdCBpcyB0aGUgcmVhc29uIG9mIHRo
+YXQ/JwoKYEluIG15IHlvdXRoLCcgc2FpZCB0aGUgc2FnZSwgYXMgaGUgc2hvb2sgaGlzIGdyZXkg
+bG9ja3MsCmBJIGtlcHQgYWxsIG15IGxpbWJzIHZlcnkgc3VwcGxlCkJ5IHRoZSB1c2Ugb2YgdGhp
+cyBvaW50bWVudC0tb25lIHNoaWxsaW5nIHRoZSBib3gtLQpBbGxvdyBtZSB0byBzZWxsIHlvdSBh
+IGNvdXBsZT8nCg==
+
+------- =_aaaaaaaaaa1
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa2"
+Content-ID: <5122.1026510654.5@ps.example.net>
+
+------- =_aaaaaaaaaa2
+Content-Type: text/plain; name="msg.23"
+Content-ID: <5122.1026510654.6@ps.example.net>
+Content-Description: Father William Part III
+Content-Transfer-Encoding: base64
+
+YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh
+awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv
+b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn
+ZSB0byBkbyBpdD8nCgpgSW4gbXkgeW91dGgsJyBzYWlkIGhpcyBmYXRoZXIsIGBJIHRvb2sgdG8g
+dGhlIGxhdywKQW5kIGFyZ3VlZCBlYWNoIGNhc2Ugd2l0aCBteSB3aWZlOwpBbmQgdGhlIG11c2N1
+bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz
+dCBvZiBteSBsaWZlLicK
+
+------- =_aaaaaaaaaa2
+Content-Type: text/plain; name="msg.24"
+Content-ID: <5122.1026510654.7@ps.example.net>
+Content-Description: Father William Part IV
+Content-Transfer-Encoding: base64
+
+YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBvbmUgd291bGQgaGFyZGx5IHN1cHBvc2UK
+VGhhdCB5b3VyIGV5ZSB3YXMgYXMgc3RlYWR5IGFzIGV2ZXI7CllldCB5b3UgYmFsYW5jZWQgYW4g
+ZWVsIG9uIHRoZSBlbmQgb2YgeW91ciBub3NlLS0KV2hhdCBtYWRlIHlvdSBzbyBhd2Z1bGx5IGNs
+ZXZlcj8nCgpgSSBoYXZlIGFuc3dlcmVkIHRocmVlIHF1ZXN0aW9ucywgYW5kIHRoYXQgaXMgZW5v
+dWdoLCcKU2FpZCBoaXMgZmF0aGVyOyBgZG9uJ3QgZ2l2ZSB5b3Vyc2VsZiBhaXJzIQpEbyB5b3Ug
+dGhpbmsgSSBjYW4gbGlzdGVuIGFsbCBkYXkgdG8gc3VjaCBzdHVmZj8KQmUgb2ZmLCBvciBJJ2xs
+IGtpY2sgeW91IGRvd24gc3RhaXJzIScK
+
+------- =_aaaaaaaaaa2--
+
+------- =_aaaaaaaaaa1--
+
+------- =_aaaaaaaaaa0--
+
+From gray@ps.example.net Sat Jan 26 10:40:08 2019
+Message-Id: <201901261040.g6CLhIb05086@example.net>
+To: Foo Bar <foobar@example.net>
+Subject: =?iso-8859-2?Q?Father_William_-_?=
+ =?iso-8859-2?Q?T=B3umaczenie_Antoniego_Marianowicza?=
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =201912093012.tXERYWQ.9301"
+Content-ID: <5082.1026510189.0@example.net>
+Date: Sat, 26 Jan 2019 12:40:18 +0200
+From: Sergey Poznyakoff <gray@ps.example.net>
+
+------- =201912093012.tXERYWQ.9301
+Content-Type: text/plain; charset=iso-8859-2
+Content-ID: <5082.1026510189.2@ps.example.net>
+Content-Description: Father William Part I
+Content-Transfer-Encoding: base64
+
+T2pjaWVjIFdpcmdpbGl1c3ogdWN6ebMgZHppZWNpIHN3b2plCk5hIGezb3dpZSBwcnp5IHR5bSBz
+dG9qsWMgd2llbGUgbGF0ClJ6ZWuzIGplZGVuIHogc3lu83c6IC0gVGFrIGJhcmR6byBzaeogYm9q
+6gpPIGNpZWJpZSBvamN6ZSwgYm+2IGp1vyBzdGFyeSBkemlhZC4KCi0gVyBsYXRhY2ggbbNvZG+2
+Y2kgLSBvamNpZWMgbXUgb2Rwb3dpZSAtCkJ5d2GzZW0gbmllcmF6IHcgc3RyYWNodSBvIHN382og
+bfN6ZywKTGVjeiBkemm2LCBnZHkgd2lkeuosIL9lIG1hbSBwdXN0byB3IGezb3dpZSwKxndpY3qx
+YywgbmFqd3m/ZWogc7N5c3rqIHdvZHkgcGx1c2su
+
+------- =201912093012.tXERYWQ.9301--
+
+From gray@example.net Sat Jan 26 10:41:48 2019
+Message-Id: <201901261041.g6CLhIb05086@example.net>
+To: Foo Bar <foobar@example.net>
+Subject: Fwd: =?utf-8?Q?Father_William_-_?=
+ =?utf-8?Q?T=C5=82umaczenie_Macieja_S=C5=82onimskiego?=
+MIME-Version: 1.0
+Content-Type: message/rfc822; name="message1"
+Content-ID: <5082.1026510189.0@ps.example.net>
+Content-Transfer-Encoding: binary
+Date: Sat, 13 Jan 2019 10:41:48 +0200
+From: Sergey Poznyakoff <gray@ps.example.net>
+
+Organization: Mailutils-tests
+Received: from example.net (localhost [127.0.0.1])
+ by example.net with ESMTP id g6CLhIb05086
+ for <gray@example.net>; Sat, 13 Jul 2002 00:43:18 +0300
+Message-Id: <200207122143.g6CLhIb05086@example.net>
+To: Foo Bar <foobar@nonexistent.net>
+Subject: =?utf-8?Q?Father_William_-_?=
+ =?utf-8?Q?T=C5=82umaczenie_Macieja_S=C5=82onimskiego?=
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =201912093012.tXERYWQ.9301"
+Content-ID: <5082.1026510189.0@example.net>
+Date: Sat, 13 Jul 2002 00:43:18 +0300
+From: Sergey Poznyakoff <gray@example.net>
+
+------- =201912093012.tXERYWQ.9301
+Content-Type: text/plain; name="msg.21"; charset=utf-8
+Content-ID: <5082.1026510189.2@example.net>
+Content-Description: Father William Part I
+Content-Transfer-Encoding: base64
+
+SmVzdGXFmyBzdGFyeSwgbcOzaiBvamN6ZSAtLSBzeW4gV2lsbGlhbWEgcnpla8WCIC0tCkkgdHdl
+IHfFgm9zeSBqdcW8IGNhxYJraWVtIHpiaWVsYcWCeTsKQ3p5IHV3YcW8YXN6IHphIHPFgnVzem5l
+LCB6d2HFvHl3c3p5IHR3w7NqIHdpZWssClN0YcSHIG5hIGfFgm93aWUgYmV6IHByemVyd3kgZHpp
+ZcWEIGNhxYJ5PwoKVyBkbmlhY2ggbcWCb2RvxZtjaSAtLSByemVrxYIgb2pjaWVjIC0tIG1hcnR3
+acWCbyBtbmllIHRvCkkgbyBtw7N6ZyBtw7NqIHdwYWRhxYJlbSB3Y2nEhcW8IHcgdHJ3b2fEmSwK
+TGVjeiBkemnFmywga2llZHkgd2llbSBqdcW8LCDFvGUgbmllIG1hbSB0YW0gZ28KTmlldXN0YW5u
+aWUgbmEgxYJiaWUgc3Rhd2HEhyBtb2fEmS4K
+
+------- =201912093012.tXERYWQ.9301--
+

Return to:

Send suggestions and report system problems to the System administrator.