X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/2c5c74d8aff556e5cd7bc10c9d555a0b2a026ed7..1ca8f21e0edfe448b71ac86de1b0cd987547a002:/sbr/encode_rfc2047.c?ds=sidebyside diff --git a/sbr/encode_rfc2047.c b/sbr/encode_rfc2047.c index 238882dc..e7ccd308 100644 --- a/sbr/encode_rfc2047.c +++ b/sbr/encode_rfc2047.c @@ -9,6 +9,8 @@ #include #include #include +#include "base64.h" +#include "unquote.h" /* * List of headers that contain addresses and as a result require special @@ -158,7 +160,7 @@ static int field_encode_quoted(const char *name, char **value, const char *charset, int ascii, int encoded, int phraserules) { - int prefixlen = name ? strlen(name) + 2: 0, outlen = 0, column, newline = 1; + int prefixlen = name ? strlen(name) + 2: 0, outlen = 0, column; int charsetlen = strlen(charset), utf8; char *output = NULL, *p, *q = NULL; @@ -173,6 +175,7 @@ field_encode_quoted(const char *name, char **value, const char *charset, utf8 = strcasecmp(charset, "UTF-8") == 0; + bool newline = true; while (*p != '\0') { /* * Start a new line, if it's time @@ -223,7 +226,7 @@ field_encode_quoted(const char *name, char **value, const char *charset, tokenlen = snprintf(q, outlen - (q - output), "=?%s?Q?", charset); q += tokenlen; column = prefixlen + tokenlen; - newline = 0; + newline = false; } /* @@ -264,7 +267,7 @@ field_encode_quoted(const char *name, char **value, const char *charset, continue; if (column >= ENCODELINELIMIT - 2) { - newline = 1; + newline = true; } else if (utf8) { /* * Okay, this is a bit weird, but to explain a bit more ... @@ -280,7 +283,7 @@ field_encode_quoted(const char *name, char **value, const char *charset, * allow for the encoded output. */ if (column + (utf8len(p) * 3) > ENCODELINELIMIT - 2) { - newline = 1; + newline = true; } } } @@ -797,8 +800,8 @@ do_reformat: output = NULL; out: - mh_xfree(tmpbuf); - mh_xfree(output); + free(tmpbuf); + free(output); return errflag > 0; }