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 4ea5edb75b238c6ca704690100128f1fe95e1d7b
parent 9e407ff5f1deb97e2e7a0e5531d08b50544638a3
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun,  2 Apr 2017 17:40:12 +0200

Show invalid encodings in parameters and headers.

Diffstat:
mime.c | 23+++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/mime.c b/mime.c @@ -118,6 +118,8 @@ mime_iconv(char *str, char *from, char *to) if (ifd == (iconv_t)-1) return NULL; + //printf("mime_iconv: '%s'; from='%s'\n", str, from); + left = strlen(str); olen = left / 2; avail = olen; @@ -153,7 +155,7 @@ mime_iconv(char *str, char *from, char *to) char * mime_decodeheaderext(char *value) { - char *work, *cret, *ret, *cs, *str, *enc, *ast; + char *work, *cret, *ret, *cs, *str, *enc, *ast, *dstr; int len, slen; len = strlen(value); @@ -209,12 +211,13 @@ mime_decodeheaderext(char *value) break; } + //printf("mime_decodeheader: mime_iconv str='%s'; cret='%s';\n", str, cret); if (cret != NULL) { free(ret); if (strcasecmp(cs, "utf-8")) { - str = mime_iconv(cret, cs, "UTF-8"); - if (str == NULL) - str = cret; + dstr = mime_iconv(cret, cs, "UTF-8"); + if (dstr == NULL) + str = smprintf("ERR(%s)", str); free(cret); } else { str = cret; @@ -342,6 +345,7 @@ mime_guessheader(char *value) gcs = NULL; + //printf("mime_guessheader '%s'\n", value); nvalue = value; if (!strisascii(value)) { /* @@ -359,7 +363,7 @@ mime_guessheader(char *value) } } - value = mime_decodeheader(nvalue); + value = mime_decodeheader(nvalue); if (gcs != NULL) free(nvalue); return value; @@ -368,7 +372,7 @@ mime_guessheader(char *value) char * mime_decodeparam(char *value) { - char *work, *cret, *ret, *cs, *str, *lang; + char *work, *cret, *ret, *cs, *str, *lang, *dstr; int len, slen; len = strlen(value); @@ -397,10 +401,9 @@ mime_decodeparam(char *value) if (cret != NULL) { if (strcasecmp(cs, "utf-8")) { free(ret); - str = mime_iconv(cret, cs, "UTF-8"); - if (str == NULL) { - str = cret; - } + dstr = mime_iconv(cret, cs, "UTF-8"); + if (dstr == NULL) + str = smprintf("ERR(%s)", str); free(cret); } else { free(ret);