Commit db61713b db61713bca989ff30c8b37f4c1155c65ce652016 by Sergey Poznyakoff

Fix improper padding in B encoding

* libmailutils/stream/fltstream.c: stop encoding when no more
input is available.
* libmailutils/tests/encode2047.at: add new tests.
* libmailutils/filter/base64.c (_base64_encoder): detect eof
1 parent 007bb14e
......@@ -232,6 +232,13 @@ _base64_encoder (void *xd,
default:
break;
}
if (iobuf->isize == 0)
{
iobuf->osize = 0;
iobuf->eof = 1;
return mu_filter_ok;
}
if (iobuf->isize <= 3)
{
......
......@@ -149,7 +149,7 @@ filter_read (mu_stream_t stream, char *buf, size_t size, size_t *pret)
if (rdsize == 0 &&
MFB_RDBYTES (fs->outbuf) == 0 &&
MFB_RDBYTES (fs->inbuf) == 0)
cmd = mu_filter_lastbuf;
break;
MFB_advance_level (&fs->inbuf, rdsize);
}
......
......@@ -14,18 +14,41 @@
# 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([encode2047])
AT_KEYWORDS([encode])
AT_CHECK([
AT_DATA(input,[dnl
\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324
dnl ------------------------------------------------------------
dnl TESTENC2047([NAME], [KW = `'], [OPT], [INPUT], [STDOUT = `'])
dnl
m4_pushdef([TESTENC2047],[
m4_pushdef([MU_TEST_GROUP],[Encode 2047])
m4_pushdef([MU_TEST_KEYWORDS],[encode2047 encode])
m4_pushdef([MU_TEST_COMMAND],[encode2047 -eB $3])
MU_GENERIC_TEST([$1],[$2],[$4],[],[$5
])
encode2047 -c koi8-r -eB -o < input],
[0],
[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=
m4_popdef([MU_TEST_COMMAND])
m4_popdef([MU_TEST_KEYWORDS])
m4_popdef([MU_TEST_GROUP])
])
AT_CLEANUP
TESTENC2047([8-bit input],[enc01],
[-c koi8-r -o],
[\\345\326\305\304\316\305\327\316\331\312\040\317\324\336\305\324],
[=?koi8-r?B?5dbFxM7F187ZyiDP1N7F1A==?=])
TESTENC2047([padding 1],[enc02],
[],
[abcd],
[=?iso-8859-1?B?YWJjZA==?=])
TESTENC2047([padding 2],[enc03],
[],
[abcdef],
[=?iso-8859-1?B?YWJjZGVm?=])
TESTENC2047([padding 3],[enc04],
[-cUTF-8],
[Wichtige Mitteilung zur Schaltung Ihres Anschlusses],
[=?UTF-8?B?V2ljaHRpZ2UgTWl0dGVpbHVuZyB6dXIgU2NoYWx0dW5nIElocmVzIEFuc2NobHVzc2Vz?=])
m4_popdef([TESTENC2047])
......