]> code.citadel.org Git - citadel.git/blobdiff - libcitadel/lib/stringbuf.c
When QP encoding, we need to convert blanks to underscores
[citadel.git] / libcitadel / lib / stringbuf.c
index 02b715397725f29a23d8c9cd69096f351a98c9dc..9ae76ca32507beeabcae41fd90152ad6bdbec01b 100644 (file)
@@ -2141,6 +2141,7 @@ long StrECMAEscAppend(StrBuf *Target, const StrBuf *Source, const char *PlainIn)
        const char *aptr, *eiptr;
        char *bptr, *eptr;
        long len;
+       int IsUtf8Sequence;
 
        if (((Source == NULL) && (PlainIn == NULL)) || (Target == NULL) )
                return -1;
@@ -2679,6 +2680,7 @@ int StrBufRFC2047encode(StrBuf **target, const StrBuf *source)
                    (ch  > 126) || 
                    (ch ==  61) ||
                    (ch == '=') ||
+                   (ch == '_') ||
                    (ch == '[') ||
                    (ch == ']')   )
                {
@@ -2686,7 +2688,10 @@ int StrBufRFC2047encode(StrBuf **target, const StrBuf *source)
                        (*target)->BufUsed += 3;
                }
                else {
-                       (*target)->buf[(*target)->BufUsed] = ch;
+                       if (ch == ' ')
+                               (*target)->buf[(*target)->BufUsed] = '_';
+                       else
+                               (*target)->buf[(*target)->BufUsed] = ch;
                        (*target)->BufUsed++;
                }
        }