When QP encoding, we need to convert blanks to underscores
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 20 Aug 2011 09:50:26 +0000 (09:50 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 20 Aug 2011 12:06:04 +0000 (12:06 +0000)
  - Spamassasin test 'BAD_ENC_HEADER' matches if a subject looks like that:
     Subject: =?UTF-8?Q?=5Btestml=5D l=C3=B6sch misch ey.?=
    it needs to look like that:
     Subject: =?UTF-8?Q?=5Btestml=5D_l=C3=B6sch_misch_ey.?=

libcitadel/lib/stringbuf.c

index f49ceb4cd77f027ceaa787849cf74f846f297030..cfe42730c4c79ff0c257d63e5288b7922ace6d5f 100644 (file)
@@ -2664,6 +2664,7 @@ int StrBufRFC2047encode(StrBuf **target, const StrBuf *source)
                    (ch  > 126) || 
                    (ch ==  61) ||
                    (ch == '=') ||
+                   (ch == '_') ||
                    (ch == '[') ||
                    (ch == ']')   )
                {
@@ -2671,7 +2672,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++;
                }
        }