From: Ken Hornstein Date: Wed, 30 Oct 2013 19:32:03 +0000 (-0400) Subject: Fix qpspecial() macro test, and do proper casts to handle signed chars. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/a54a8b6b0f8d31ff9ae01215aaa59de5491fc54e?ds=sidebyside;hp=448debd081b8bfad38ba43b21bea34a9c0eb49c2 Fix qpspecial() macro test, and do proper casts to handle signed chars. --- diff --git a/sbr/encode_rfc2047.c b/sbr/encode_rfc2047.c index 4cacd837..3bd22ac3 100644 --- a/sbr/encode_rfc2047.c +++ b/sbr/encode_rfc2047.c @@ -37,7 +37,7 @@ static char *address_headers[] = { #define is_fws(c) (c == '\t' || c == ' ') -#define qpspecial(c) (c < ' ' || c == '=' && c == '?' && c == '_') +#define qpspecial(c) (c < ' ' || c == '=' || c == '?' || c == '_') #define ENCODELINELIMIT 76 @@ -66,7 +66,7 @@ encode_rfc2047(const char *name, char **value, int encoding, for (p = *value; *p != '\0'; p++) { if (isascii((int) *p)) { asciicount++; - if (qpspecial(*p)) + if (qpspecial((int) *p)) qpspecialcount++; } else eightbitcount++; @@ -223,7 +223,7 @@ field_encode_quoted(const char *name, char **value, const char *charset, if (*p == ' ') { *q++ = '_'; ascii--; - } else if (!qpspecial(*p)) { + } else if (isascii((int) *p) && !qpspecial((int) *p)) { *q++ = *p; ascii--; } else {