Only ignore linear-white-space between two encoded-words, lax
[infodrom/newmail] / rfc2047.c
index 4afd04a..cd6cc4b 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -137,8 +137,9 @@ char *convert_header(char *buf)
 
   while ((encstart = strstr (inp, "=?"))) {
     if (encstart != inp) {
-      memcpy (outp, inp, encstart-inp-1);
-      outp += encstart-inp-1;
+      // -1 nur falls vorher kein encoded-word
+      memcpy (outp, inp, encstart-inp);
+      outp += encstart-inp;
     }
     charset = encstart+2;
 
@@ -171,6 +172,10 @@ char *convert_header(char *buf)
     *wordp = '\0';
     wordp += 2;
 
+    /* Look for next =?, spaces will be eaten between two encoded-words */
+    if (*wordp && *wordp == ' ' && *(wordp+1) && *(wordp+1) == '=' && *(wordp+2) && *(wordp+2) == '?')
+      wordp++;
+
     switch (encoding) {
     case 'B':
       decode = decode_base64 (inp);