]> diplodocus.org Git - nmh/commitdiff
Fix qpspecial() macro test, and do proper casts to handle signed chars.
authorKen Hornstein <kenh@pobox.com>
Wed, 30 Oct 2013 19:32:03 +0000 (15:32 -0400)
committerKen Hornstein <kenh@pobox.com>
Wed, 30 Oct 2013 19:32:03 +0000 (15:32 -0400)
sbr/encode_rfc2047.c

index 4cacd8379d1b055b3be140b76a7a3a1987e783f3..3bd22ac38ce7f8cb6868c707ba4e93485c7d63c0 100644 (file)
@@ -37,7 +37,7 @@ static char *address_headers[] = {
 
 #define is_fws(c) (c == '\t' || c == ' ')
 
 
 #define is_fws(c) (c == '\t' || c == ' ')
 
-#define qpspecial(c) (c < ' ' || c == '=' && c == '?' && c == '_')
+#define qpspecial(c) (c < ' ' || c == '=' || c == '?' || c == '_')
 
 #define ENCODELINELIMIT        76
 
 
 #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++;
     for (p = *value; *p != '\0'; p++) {
        if (isascii((int) *p)) {
            asciicount++;
-           if (qpspecial(*p))
+           if (qpspecial((int) *p))
                qpspecialcount++;
        } else
            eightbitcount++;
                qpspecialcount++;
        } else
            eightbitcount++;
@@ -223,7 +223,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
        if (*p == ' ') {
            *q++ = '_';
            ascii--;
        if (*p == ' ') {
            *q++ = '_';
            ascii--;
-       } else if (!qpspecial(*p)) {
+       } else if (isascii((int) *p) && !qpspecial((int) *p)) {
            *q++ = *p;
            ascii--;
        } else {
            *q++ = *p;
            ascii--;
        } else {