rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | LICENSE

commit 9e407ff5f1deb97e2e7a0e5531d08b50544638a3
parent c4140c56b7d1d9a29bda32e018e57b2782caa1eb
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun,  2 Apr 2017 17:07:44 +0200

Base64 compatible to Mozilla Thunderbird.

Diffstat:
base64.c | 25++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/base64.c b/base64.c @@ -71,7 +71,7 @@ char * b64dec(char *istr, int *len) { char *ret, str[5]; - int p, po; + int p, po, l, uglyline; char bd[256]; memset(bd, 0x80, 256); @@ -84,6 +84,29 @@ b64dec(char *istr, int *len) po = 0; ret = NULL; + /* + * If there is something prepended to the base64 block, take it as-is. + */ + for (uglyline = 1; uglyline == 1; l = p) { + uglyline = 0; + for (; istr[l] != '\n' && istr[l]; l++) { + if (istr[l] == ' ') + uglyline = 1; + } + /* Take care of empty lines. */ + if ((l - p) == 1 && istr[l-1] == '\r') + uglyline = 1; + if ((l - p) == 0) + uglyline = 1; + if (uglyline) + po = p = l + 1; + } + if (p > 0) { + ret = reallocz(ret, l, 0); + memmove(ret, istr, p+1); + } + + for (; !readnwstr(str, istr, &p, *len, 4); po += 3) { ret = reallocz(ret, po + 4, 0);